Home

Awesome

EighthBridge

Interactive graph modeling and rendering for ScalaFX

Introduction

GraphPlan screenshot

EighthBridge is a ScalaFX library dedicated to:

EighthBridge stems from both the old Arcontes library (introduced to support a previous version of GraphsJ) and my experience with the Elm language - which I studied while creating my first HTML 5 videogame - Solvenius.

In particular, EighthBridge's most important aspect is that the graph model is immutable - adding a vertex, for example, creates a new graph.

Such solution, derived from purely functional programming, definitely increased the conciseness, simplicity and robustness of the model, dramatically speeding up development.

Mutability is still present where more natural and sometimes almost required - in the ScalaFX components - making EighthBridge a hybrid OOP-functional library, perfectly supported by Scala's hybrid, very elegant nature.

To further focus on the declarative nature of EighthBridge, graphs must be skinned using standard JavaFX CSS stylesheets (see below).

Requirements

Scala 2.11.8 or later and Java 8u91 or later are recommended to employ EighthBridge.

Referencing the library

EighthBridge is available on Hephaestus and can be declared as a Gradle or Maven dependency; please refer to its dedicated page.

Alternatively, you could download the JAR file from Hephaestus and manually add it to your project structure.

Finally, EighthBridge is also a standard OSGi bundle which you can employ in your OSGi architectures! ^__^

Core concepts

EighthBridge is designed to be simple and minimalist; however, we could now go through a brief overview of the most important traits and classes:

For further information, a basic documentation can be found in its Scaladoc, which can be downloaded from the library's section in Hephaestus. Finally, the full open source code is available on GitHub.

Enhanced graph interaction

Starting from version 3, EighthBridge automatically provides interactive features very similar to map navigation:

Styling graphs with CSS

Starting from EighthBridge 2, the visual properties (fonts, colors) of graphs, vertexes and links are to be declared in standard JavaFX CSS files.

PLEASE, NOTE: CSS styling is mandatory, not optional: if you forget to add CSS declarations for your graphs, GraphCanvas will only show a black rectangle.

To include the default CSS stylesheet, providing very sensible (and overridable) defaults, just add this line of code to the initialization of any scene using EighthBridge:

scene.getStylesheets.addAll(
  BasicStyles.resourceUrl.toExternalForm,

  //Your additional CSS resources, if any
)

The CSS tree for the "basic" package

To create your own CSS files that customize the visual appearance of the renderers provided by the basic package, please use the following CSS selectors:

PLEASE, NOTE: VisualVertex and VisualLink also have a styleClasses property, whose values are appended to the default class for the renderer (.vertex and .link, respectively). In other words, if you assign a vertex a styleClass named solution, you can style its label using this selector:

.solution > .label

About the name

The name EighthBridge derives from the famous problem of the 7 bridges of Königsberg, negatively solved by Leonhard Euler: more precisely, the famous mathematician introduced the concept of graph to demonstrate that the problem had no solution; however, the problem can be positively solved if, for example, we think out of the box and introduce... a suitable eighth bridge! ^__^

Further references