Force layout


Source link: https://github.com/kai0masanari/Forcelayout

Force layout

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

Demo

Usage

Usage in kotlin

1. Gradle

repositories {

  jcenter() 
}
  dependencies {

  compile 'jp.kai:forcelayout:1.0.9' 
}

2. Definitions of nodes

val nodes = ArrayList <Pair<String,Int>>() nodes.add(Pair("nodeName1", R.drawable.example1)) nodes.add(Pair("nodeName2", R.drawable.example2)) nodes.add(Pair("nodeName3", R.drawable.example3))

or

val nodes: Nodes = Nodes() nodes.add(NodePair("nodeName1", R.drawable.example1)) nodes.add(NodePair("nodeName2", R.drawable.example2)) nodes.add(NodePair("nodeName3", R.drawable.example3))

If you don't use image. You can just write node name.

val nodes: Array<String> = arrayOf( "nodeName1", "nodeName2", "nodeName3")

3. Definitions of links

val links = Arrays.asList("nodeName1-nodeName2", "nodeName1-nodeName3")

or

val links: Links = Links() links.add(LinkPair("nodeName1", "nodeName2")) links.add(LinkPair("nodeName1", "nodeName3"))

4. Set node and link style (optional)

val forcelayout = Forcelayout(applicationContext)  forcelayout.node()
  .size(100)
  .style(Color.argb(100,200,30,50))  forcelayout.link()
  .style(Color.argb(60,50,30,200), 5.0f)

5. Set nodes and links

You can set node's size and link-strength, and so on. Please use anko if you write in kotlin.

val forcelayout = Forcelayout(applicationContext)
forcelayout.with(this)  .size(200)  .distance(200)  .gravity(0.04)  .friction(0.04)  .nodes(nodes)  .links(links)  .start()
Params Description
size To set image width.
distance To set distance between each nodes.
gravity To set gravitation.
friction To set gravitation between pair of nodes.
nodes To set nodes that contain node name and image.
links To set pairs that contain node names.

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. 

Resources

Vinyl is an annotation processor that makes it simple to work with Cursors and ContentValues using your application's domain language.

Simple autosizing TextView for Android.

Capture debug logging to a file that user can easily send to you via email.

Cache support for android VideoView.

A Toggling Add/Remove button.

Drop-down menu for Android which allows to filter the items using multiple condition.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes