mihosoft.eu
Programming, Art, Linux, Free Software…
mihosoft.eu
Navigation
  • Home
  • VRL-Studio
  • SonoAir
  • Monochrome Wars
  • About
  • Impressum
  • Datenschutz
You are here: Home › Featured › Workflow Visualization With VWorkflows & JavaFX [Part 2]

Workflow Visualization With VWorkflows & JavaFX [Part 2]

May 3, 2013 | Filed under: Featured, JavaFX, VRL and tagged with: graph, Java, JavaFX, JFXtras, VRL, VRL-Studio, window control, Window Node, Window System, workflow, workflows

This is the second part of the VWorkflows tutorial. In the first part we demonstrated how to create nodes, define connections and how to visualize them with JavaFX.

Thanks for all your feedback! This was the motivation for me to create this second tutorial.

UPDATE [23.05.2014]: This tutorial has been updated to work with recent versions of VWorkflows.

Overview

In this tutorial you will learn how to

  • set node location, width and height
  • create subflows
  • use selective visualization to handle large flows with thousands of flow nodes
  • search nodes by global ids
  • create complex flows

VWorkflows Still Needs Your Contribution!

Are you interested in creating flow visualizations with JavaFX? Currently, the library is in an early state. So this is ideal for contributing ideas on how the library should be designed. We’d love to integrate your contributions. Feel free to contact us!

Specify Node Location & Size

Position and size information is currently part of the node model:

// define node position
n.setX(10)
n.setY(10)

// define node size
n.setWidth(160)
n.setHeight(100)

Note: The user interface binding is responsible for evaluating the layout data. It is an optional information that does not influence the flow itself. The default ui binding for JavaFX makes use of it and uses it to layout the node skins.

Creating Subflows

To create a subflow call the newSubFlow() method. This will return a new flow controller object that has the same functionality as the parent/root flow:

// create a new flow object (see tutorial 1)
VFlow flow = FlowFactory.newFlow();

// create a leaf node (see tutorial 1)
VNode n = flow.newNode();

// create subflow
VFlow subflow = flow.newSubFlow();

// add nodes to the subflow
VNode sn1 = subflow.newNode();
VNode sn2 = subflow.newNode();

With the default JavaFX based ui binding the flow will look like this:

Subflows

Subflows

Selective Visualization

By default subflows don’t show their content. This is an optimization that is necessary to allow large flows with thousands of nodes to be visualized. Thje user can enable the visualizations for the parts he is interested in. The API call for this is as simple as:

flow.setVisible(true) // enables visualization of flows content

The ui binding does not have to watch this property. The backend calls the add/remove methods of the node skins automatically. The default JavaFX based ui binding displays an icon (right side of the titlebar) that can be clicked to show/hide the content of a flow node:

Selective Visualization

Selective Visualization

Complex Flow Example

Here is a complex flow example that recursively creates a flow with the specified layer width and depth:

/**
 * Creates a flow with specified width and depth.
 * @param workflow parent workflow
 * @param depth flow depth (number of nested nodes)
 * @param width flow width (number of nodes per layer)
 */
public void createFlow(VFlow workflow, int depth, int width) {

    // stop if we reached deppest layer
    if (depth < 1) {
        return;
    }

    // create nodes in current layer
    for (int i = 0; i < width; i++) {

        VNode n;

        // every second node shall be a subflow
        if (i % 2 == 0) {
            // create subflow
            VFlow subFlow = workflow.newSubFlow();
            n = subFlow.getModel();
            createFlow(subFlow, depth - 1, width);
        } else {
            //create leaf node
            n = workflow.newNode();
        }

        n.setTitle("Node " + i);

        // every third node shall have the same connection type
        // colors for "control", "data" and "event" are currently hardcoded
        // in skin. This will change!
        if (i % 3 == 0) {
            n.addInput("control");
            n.addOutput("control");
        } else if (i % 3 == 1) {
            n.addInput("data");
            n.addOutput("data");
        } else if (i % 3 == 2) {
            n.addInput("event");
            n.addOutput("event");
        }

        // specify node size
        n.setWidth(300);
        n.setHeight(200);

        // gap between nodes
        int gap = 30;

        int numNodesPerRow = 5;

        // specify node position (we use grid layout)
        n.setX(gap+(i % numNodesPerRow) * (n.getWidth() + gap));
        n.setY(gap+(i / numNodesPerRow) * (n.getHeight() + gap));
    }
}

This is how the result will look like:

Complex Workflows 01

Complex Workflows 01

Complex Workflows 02

Complex Workflows 02

Search Nodes By Global Id

Each node can be accessed by its id. Assume the following flow:

VNode n1 = flow.newNode();
VNode n2 = flow.newNode();
VFlow f1 = flow.newSubFlow()
VNode n3 = f1.newNode() // assume this node has id "4"

If you know the node id you can perform a global search by calling:

VNode n = flow.getFlowNodeLookup().getById("4")

Demo application

Download the tutorial code from GitHub.

Requirements:

  • Java 8
  • Optional: Netbeans >=7.4 with Gradle Plugin

Building & Running:

To compile from the command line just type ./gradlew build. Run it with ./gradlew run.

Next steps

Download VWorkflows and create your own flow visualization apps/controls.

Stay tuned and follow me on Twitter

To be continued…

Update: here is part 3

Did you like this article? Share it with your friends!

Tweet

Written by admin

Visit my Website Follow me on Twitter

7 Responses to "Workflow Visualization With VWorkflows & JavaFX [Part 2]"

  1. Andy Till says:
    May 4, 2013 at 14:48

    Very nice blue skin but I can’t see a lot of CSS in your project, how are you styling it?

    1. miho says:
      May 4, 2013 at 15:06

      Update [23.05.2014]: CSS support has been highly improved. See here for a CSS sample.

      The styling of the windows is currently done in the VWorkflows project. It’s just on line:

      setStyle("-fx-background-color: rgba(120,140,255,0.2);-fx-border-color: rgba(120,140,255,0.42);-fx-border-width: 2;");
      

      For connection colors some style properties are currently defined programmatically. I’ll improve the code and write a tutorial on how to customize the ui. Maybe next week or so. You may also have a look at the window control in the JFXtras project. There are the CSS files for the window icons.

  2. Java desktop links of the week, May 6 | Jonathan Giles says:
    May 5, 2013 at 23:12

    […] mihosoft has published part two of the series of posts on workflow visualization with VWorkflows & JavaFX. […]

  3. Alexey says:
    September 22, 2013 at 17:45

    how can I find parent nodes of a node?

    I can find the fist input connector with :

    Connector firstConnector = node.getInputs().get(0);

    and how can I find the connection for the connector now?

    1. miho says:
      September 23, 2013 at 01:06

      how can I find parent nodes of a node?

      node.getFlow()
      

      and how can I find the connection for the connector now?

      Collection<Connection> connections
           = node.getFlow().getConnections(
                  firstConnector.getType()).
                  getAllWith(firstConnector.getId());
      

      Consider posting to the mailing list:

      https://groups.google.com/forum/#!forum/vrl-developers

  4. Torsten says:
    December 4, 2013 at 17:16

    Nice Tooling!!!. Can I connect nodes that reside in different subflows? The API programmtically allows it, but it does not seem to work. Thanks, Torsten

    1. miho says:
      December 5, 2013 at 13:50

      Nice Tooling!!!

      Thanks 🙂

      Can I connect nodes that reside in different subflows?

      It should work in the model (please create a bugreport on github if it doesn’t). The JavaFX UI does currently not support this. But since the model and the UI are separated you are free to implement this feature in the UI. If you need help with the implementation we can discuss this on the forum: https://groups.google.com/forum/#!forum/vrl-developers

Comments are closed.

Pages

  • About
  • Datenschutz
  • Impressum
  • Seminar 2019

Categories

  • 3D Printing
  • Any-Key
  • Art
  • C/C++
  • Devoxx
  • Digital Painting
  • Featured
  • IoT
  • Java
  • JavaFX
  • Javakurs 2015
  • JavaOne
  • Linux
  • Linux on Apple Hardware
  • Linux: Daily Usage Tips
  • Mobile Apps
  • Mobile Devices
  • Programming Languages
  • Repair Things
  • Science
  • Sonos
  • Teaching
  • Uncategorized
  • Virtual Reality
  • VRL

Tags

3D 3D Printing 3d visualization AirSonos Apple Music Devoxx Devoxx 2013 gradle graph iOS Java Java 8 JavaFX JavaFX 8 JavaOne JavaOne 2013 jdk9 JFXtras JInternalFrame Linux MacBook MDI mobile apps OpenDive OpenJDK OpenJFX Open Source Performance scientific visualization SonoAir Sonos Ultimaker Virtual Reality Virtual World visual programming VPlot VRL VRL-Studio VWorkflows window control Window Node Window System workflow workflows X11

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

JavaOne Rockstar

JavaOne Rockstar
Follow @mihosoft

Recent Posts

  • Native JDK9 Application Bundles
  • Running C code from Java via VTCC
  • SonoAir finally supports macOS High Sierra!
  • JavaOne 2017 Community Keynote Artwork
  • The JGrounds App: better teaching apps for Java 9 [BOF5047]

Recent Comments

  • ¿Ventanas completamente personalizadas de JavaFX? - Fallosweb.com on VFXWindows
  • JavaFX entirely customized windows? – w3toppers.com on VFXWindows
  • Volel Mondesir on Adding Custom Icons to JFXtras Window Control (VFXWindows)
  • Volel Mondesir on Adding Custom Icons to JFXtras Window Control (VFXWindows)
  • Switching between different JDK versions in Windows - ErrorsFixing on JSelect: switch between different JDK versions

Archives

  • February 2018
  • October 2017
  • September 2017
  • February 2017
  • June 2016
  • May 2016
  • November 2015
  • September 2015
  • July 2015
  • March 2015
  • September 2014
  • March 2014
  • February 2014
  • December 2013
  • November 2013
  • October 2013
  • September 2013
  • August 2013
  • July 2013
  • June 2013
  • May 2013
  • April 2013
  • March 2013
  • February 2013
  • October 2012
  • September 2012
  • August 2012
  • July 2012
  • November 2010
  • February 2010
  • November 2009
  • October 2009
  • February 2009
  • August 2008
  • May 2008
  • April 2008
  • March 2008
Privacy & Cookies: this site uses cookies. By continuing to use this website, you agree to their use.
To find out more, see here: Impressum & Datenschutz

© 2025 mihosoft.eu