Coder Social home page Coder Social logo

Comments (11)

tomnelson avatar tomnelson commented on June 3, 2024 1

If you want to see your graph with many different layouts, I pushed a demo called ShowLayoutsWithIO7MGraph to the master branch.

from jungrapht-visualization.

tomnelson avatar tomnelson commented on June 3, 2024

Thanks for your interest!
There are 2 demos:

L2RTreeLayoutDemo
TidierL2RTreeLayoutDemo

The code that maps the layout L2R is this:

vv.getVisualizationModel()
    .getLayoutModel()
    .getLayoutStateChangeSupport()
    .addLayoutStateChangeListener(
        evt -> {
          if (!evt.active) {
            LayoutModel<String> layoutModel = evt.layoutModel;
            layoutModel
                .getLocations()
                .forEach(
                    (v, p) -> layoutModel.set(v, Point.of(p.y, layoutModel.getWidth() - p.x)));
          }
        });

If you want to go from right to left, like your example image, change it like this:
.forEach(
(v, p) -> layoutModel.set(v, Point.of(
layoutModel.getHeight() - p.y, p.x)));

from jungrapht-visualization.

io7m avatar io7m commented on June 3, 2024

Ah, thanks, I'll give it a try!

I've been unable to get any of the demo code to run as the latest Intellij IDEA seems to have serious problems opening the project. For whatever reason, it consistently manages to open the modules in a broken state.

from jungrapht-visualization.

tomnelson avatar tomnelson commented on June 3, 2024

I use Intellij IDEA for development, so I run the demos with it all the time.
I just downloaded the latest version (2022.3.2) and did not have any problems.

To test it everything, I did this:

git clone [email protected]:tomnelson/jungrapht-visualization.git
cd jungrapht-visualization
mvn clean install

After building it, I used File -> Open
and made a new project like this:
image

from jungrapht-visualization.

io7m avatar io7m commented on June 3, 2024

Following those exact steps, I get a project that has no Maven modules and no source directories configured:

ide

It's possible to go through and manually set source directories, but notice that it also fails to include any Maven dependencies, and even the "Repair IDE..." option that takes me through a ton of steps to clear indices, reindex, etc, fails in the end.

ide2

I've not seen this happen with a Maven project before.

from jungrapht-visualization.

io7m avatar io7m commented on June 3, 2024

Checking to see if this is still the case on the latest version... ⌛

from jungrapht-visualization.

tomnelson avatar tomnelson commented on June 3, 2024

Mine looks like this, in the maven panel:
image

You might try invalidating the caches and loading the project again. I can't think of any other things to try.
I've never manually set source directories.

from jungrapht-visualization.

io7m avatar io7m commented on June 3, 2024

It appears it was a bug with the 2022.2.4 version. It imports fine with 2022.3.2. Sorry for the noise!

from jungrapht-visualization.

tomnelson avatar tomnelson commented on June 3, 2024

Glad you found a solution.
For what its worth, your question led me to think of a way to change the layout direction within the
jungrapht-layout module. I want the layouts to be independent of the visualization layer and any awt classes, so the layouts can be used with a different rendering system.

The layout algorithms can take an 'after' function (a Runnable) that runs when they are done.
I pushed some changes to the master branch. I think this approach is better.

from jungrapht-visualization.

io7m avatar io7m commented on June 3, 2024

I'm still working on this, although I've not been able to tune the code sufficiently to get the sort of output I'm looking for yet.

To clarify, I'm working on a patch editor for some audio effects hardware. The signal chain on the hardware is configured as a simple directed graph with a fixed number of possible branches. I wrote a very simple stack-based graph layout algorithm here:

https://github.com/io7m/gatwick/blob/develop/com.io7m.gatwick.gui/src/main/java/com/io7m/gatwick/gui/internal/preset/GWNodeArranger.java

This produces output like this:

graph_k

This is fine, but there are occasionally graphs for which the algorithm breaks. Rather than try to exhaustively track down every last edge case, I thought it might be a better idea to look at a general purpose graph layout library. I've not yet been able to get jungrapht to produce graphs that are as compact, but I'll try to post some code when I have something concrete that gets most of the way there. 🙂

Edit: I do my own edge rendering, so I actually only need the vertex positions.

from jungrapht-visualization.

tomnelson avatar tomnelson commented on June 3, 2024

I don't have a layout algorithm that would produce that output. If I had an Orthogonal layout algorithm, it could be close, but you need to make some placement decisions based on the types of the endpoints.

This is the closest I could get, using the EiglspergerLayoutAlgorithm and rotating it:

image

from jungrapht-visualization.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.