Force layout

Additional

Language
Java
Version
N/A
Created
Sep 3, 2016
Updated
Oct 5, 2016
Owner
kai toyama (kai0masanari)
Contributor
kai toyama (kai0masanari)
1
Activity
Badge
Generate
Download
Source code

Advertisement

Force layout

Forcelayout is an Android library for visualizing data. You can drawing graph with spring-like attractive forces.

Demo

Usage

1. Gradle

repositories {
    jcenter()
}

dependencies {
    compile 'jp.kai:forcelayout:1.0.4'
}

2. Definitions of nodes

HashMap<String, Integer> nodes = new HashMap<>();

nodes.put("labelname_1",R.drawable.example1);
nodes.put("labelname_2",R.drawable.example2);

3. Definitions of links

List<String> links = new ArrayList<String>();

links.put("labelname_1-labelname_2");

4. Set nodes and links

You can set node's size and linkstrength, and so on.

Forcelayout.with(this)
    .nodesize(200)
    .linkStrength(0.1)
    .distance(200)
    .gravity(0.04)
    .nodes(nodes)
    .links(links);

or

Forcelayout.node().nodesize(150).nodes(nodes).drawLable(true);
Forcelayout.link().links(links).style(10, Color.RED).drawStroke(true);

Forcelayout.with(this)
    .linkStrength(0.1)
    .distance(200)
    .gravity(0.04);

Thanks

Inspired by force layout in D3.js.

License


Copyright 2016 kai0masanari

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.