GithubHelp home page GithubHelp logo

rshandy / bubble-sets Goto Github PK

View Code? Open in Web Editor NEW

This project forked from josuakrause/bubble-sets

0.0 1.0 0.0 438 KB

An implementation of bubble sets without the use of external libraries.

Home Page: http://faculty.uoit.ca/collins/research/bubblesets/

License: MIT License

Java 100.00%

bubble-sets's Introduction

Bubble Sets

This is an implementation of [bubble sets] 1 without the use of external libraries.

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:

@Override
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
        g.setColor(Color.ORANGE);
        g.fill(shape);

        // and then the outlines
        g.setColor(Color.BLACK);
        g.draw(shape);
    }
}

The following set outlines are available:

  • setvis.ch.ConvexHull
  • 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)::

<dependency>
  <groupId>joschi-mvn</groupId>
  <artifactId>Bubble-Sets</artifactId>
  <version>0.0.1</version>
</dependency>

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

<repository>
    <id>joschi</id>
    <url>http://josuakrause.github.io/info/mvn-repo/releases</url>
</repository>

bubble-sets's People

Contributors

josuakrause avatar christophermcollins avatar

Watchers

James Cloos avatar

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.