Skip to content
A Java implementation of Bubble Sets.
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.


Type Name Latest commit message Commit time
Failed to load latest commit information.

Bubble Sets

A Java implementation of Christopher Collins' [bubble sets] 1 without the use of external libraries. A JavaScript implementation can be found here.

This project can be build in eclipse as well as with Maven. Use mvn install to generate jars in the target/ directory. The Bubble-Sets-X.X.X.jar contains the API for the bubble sets and Bubble-Sets-X.X.X-example.jar contains a little example program showing the bubble sets. Alternatively the project can be used as dependency in other Maven projects (see [below] (#maven-integration)).

To get started, you can use the following code:

// a list of groups of rectangles --
// bubble set will try to create an outline with
// as little overlap between the groups as possible
List<Rectangle2D[]> items = ...;

// using bubble set outlines
SetOutline setOutline = new BubbleSet();

// make the outlines smooth
AbstractShapeGenerator shapeGenerator = new BezierShapeGenerator(setOutline);

// generate shapes for each group
// the shapes can be drawn by a Graphics object
// as passed by a component's paint method
Shape[] shapes = shapeGenerator.createShapesFor(items);

A more advanced example uses groups which can also define lines that guide the iso-contour. It also shows a possible use within a paint method:

public void paint(final Graphics gfx) {
    // using graphics 2d
    Graphics2D g = (Graphics2D) gfx;

    // the list of groups
    List<Group> items = null;

    // use bubble sets and make the outlines smooth and less complex
    // to draw by simplifying the raw points
    AbstractShapeGenerator shapeGenerator = new ShapeSimplifier(
            new BSplineShapeGenerator(new ShapeSimplifier(
                    new PolygonShapeGenerator(new BubbleSet()))), 2.0);

    // generate shapes for each group
    Shape[] shapes = shapeGenerator.createShapesForGroups(items);

    for (Shape shape : shapes) {
        // drawing the content

        // and then the outlines

The following set outlines are available:

  • setvis.bubbleset.BubbleSet

And the following shape generators:

  • setvis.shape.PolygonShapeGenerator
  • setvis.shape.BezierShapeGenerator
  • setvis.shape.BSplineShapeGenerator
  • setvis.shape.ShapeSimplifier (reduces the shape complexity)

Maven Integration

In order to use bubble sets within a Maven project you can use the following dependency (in the <dependencies> section)::


However, this requires an additional repository in the repositories section (<repositories>) of the pom.xml file:

You can’t perform that action at this time.