Tree View; Mind map; Think map; tree map; custom view; 自定义; 树状图;思维导图;组织机构图;层次图

Overview

GysoTreeView

中文】【English If ok, give me a star

Tree View; Mind map; Think map; tree map; 树状图;思维导图;组织机构图;层次图;树型图

A custom tree view for Android, designed for easy drawing some tree nodes (e.g. thind mind and tree nodes). Includes smoothly zoom, move, limit and center fix animation support, and allows easy extension so you can add your own child node's customs view and touch event detection.

Funtions

  • 🍇 Smoothly zoom, move
  • 🍈 Fix your window view port
  • 🍉 Custom your subview for special node
  • 🍊 Custom lines between nodes
  • 🍋 Dynamic remove nodes
  • 🍌 Dynamic add nodes
  • 🥭 Drag to rebuild the nodes' relationship

Releases & downloads

Base--Line, LayoutManger, Custom node view

Add

Remove

Drag Edit Mode

Click

Zoom and Fit Window

Steps for use

    <com.gyso.treeview.GysoTreeView
        android:id="@+id/base_tree_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/colorBackground">
    </com.gyso.treeview.GysoTreeView>

Before presentation, Animal class means you own bean class, like this:

public class Animal {
    public int headId;
    public String name;
}

To use a tree view, you should do 5 steps as follows:

  1. Customs adapter by extends TreeViewAdapter.

    public class AnimalTreeViewAdapter extends TreeViewAdapter<Animal> {
        private DashLine dashLine =  new DashLine(Color.parseColor("#F06292"),6);
        @Override
        public TreeViewHolder<Animal> onCreateViewHolder(@NonNull ViewGroup viewGroup, NodeModel<Animal> node) {
            //TODO in inflate item view
            NodeBaseLayoutBinding nodeBinding = NodeBaseLayoutBinding.inflate(LayoutInflater.from(viewGroup.getContext()),viewGroup,false);
            return new TreeViewHolder<>(nodeBinding.getRoot(),node);
        }
    
        @Override
        public void onBindViewHolder(@NonNull TreeViewHolder<Animal> holder) {
            //TODO get view and node from holder, and then control your item view
            View itemView = holder.getView();
            NodeModel<Animal> node = holder.getNode();
    		...
        }
    
        @Override
        public Baseline onDrawLine(DrawInfo drawInfo) {
            // TODO If you return an BaseLine, line will be draw by the return one instead of TreeViewLayoutManager's
    		// if(...){
            //   ...
            // 	 return dashLine;
       		// }
            return null;
        }
    }
  2. configure layout manager. Space unit is dp. You can custom you line by extends {@link com.gyso.treeview.line.BaseLine}

    int space_50dp = 50;
    int space_20dp = 20;
    //choose a demo line or a customs line. StraightLine, PointedLine, DashLine, SmoothLine are available.
    Baseline line =  new DashLine(Color.parseColor("#4DB6AC"),8);
    //choose layoout manager. VerticalTreeLayoutManager,RightTreeLayoutManager are available.
    TreeLayoutManager treeLayoutManager = new RightTreeLayoutManager(this,space_50dp,space_20dp,line);
  3. setting adapter and layout manager for your tree view.

    ...
    treeView = findViewById(R.id.tree_view);   
    TreeViewAdapter adapter = new AnimlTreeViewAdapter();
    treeView.setAdapter(adapter);
    treeView.setTreeLayoutManager(treeLayoutManager);
    ...
  4. nodes data setting

    //Create a TreeModel by using a root node.
    NodeModel<Animal> node0 = new NodeModel<>(new Animal(R.drawable.ic_01,"root"));
    TreeModel<Animal> treeModel = new TreeModel<>(node0);
    
    //Other nodes.
    NodeModel<Animal> node1 = new NodeModel<>(new Animal(R.drawable.ic_02,"sub0"));
    NodeModel<Animal> node2 = new NodeModel<>(new Animal(R.drawable.ic_03,"sub1"));
    NodeModel<Animal> node3 = new NodeModel<>(new Animal(R.drawable.ic_04,"sub2"));
    NodeModel<Animal> node4 = new NodeModel<>(new Animal(R.drawable.ic_05,"sub3"));
    NodeModel<Animal> node5 = new NodeModel<>(new Animal(R.drawable.ic_06,"sub4"));
    
    
    //Build the relationship between parent node and childs,like:
    //treeModel.add(parent, child1, child2, ...., childN);
    treeModel.add(node0, node1, node2);
    treeModel.add(node1, node3, node4);
    treeModel.add(node2, node5);
    
    //finally set this treeModel to the adapter
    adapter.setTreeModel(treeModel);
  5. If your want to edit your tree view, please use an editor.

final TreeViewEditor editor = binding.baseTreeView.getEditor();

//add nodes
NodeModel<Animal> a = new NodeModel<>(new Animal(R.drawable.ic_13,"add-" + atomicInteger.getAndIncrement()));
NodeModel<Animal> b = new NodeModel<>(new Animal(R.drawable.ic_10,"add-" + atomicInteger.getAndIncrement()));
NodeModel<Animal> c = new NodeModel<>(new Animal(R.drawable.ic_11,"add-" + atomicInteger.getAndIncrement()));
editor.addChildNodes(targetNode,a,b,c);

//remove node
editor.removeNode(toRemoveNode);

//view center in window viewport
editor.focusMidLocation()
    
//drag to move and build new relationship
editor.requestMoveNodeByDragging(isChecked);

Notes & limitations

Firstly, only vertical-down derection layout and right direction layout is available, more layout style should be code.

Secondly, customing lines by extends BaseLine may be a little complicate for Android beginner, and performance issues will happen if you using carefully.

Finally, this custom view will be continuely improved, if you has some innovative ideas, please tell me. Thanks for you patience.

I will tell you how it works on my CSDN blogs.

You might also like...

Custom captions (window decorations) on Windows for JavaFX

javafx-customcaption javafx-customcaption is designed to allow customizing the native window caption on Microsoft Windows Usage: You can use the follo

Dec 15, 2022

Open Weather Map API wrapper for Java.

Java Open Weather API Wrapper Open Weather Map API wrapper for Java. This project allows you to seamlessly implement the Open Weather Map API into you

Feb 6, 2022

Immutable in-memory R-tree and R*-tree implementations in Java with reactive api

Immutable in-memory R-tree and R*-tree implementations in Java with reactive api

rtree In-memory immutable 2D R-tree implementation in java using RxJava Observables for reactive processing of search results. Status: released to Mav

Dec 20, 2022

An application metrics facade for the most popular monitoring tools. Think SLF4J, but for metrics.

Micrometer Application Metrics An application metrics facade for the most popular monitoring tools. Instrument your code with dimensional metrics with

Dec 30, 2022

A powerful 🚀 Android chart view / graph view library, supporting line- bar- pie- radar- bubble- and candlestick charts as well as scaling, panning and animations.

A powerful 🚀 Android chart view / graph view library, supporting line- bar- pie- radar- bubble- and candlestick charts as well as scaling, panning and animations.

⚡ A powerful & easy to use chart library for Android ⚡ Charts is the iOS version of this library Table of Contents Quick Start Gradle Maven Documentat

Jan 9, 2023

An Android library for member secretGFX group, This can be used to growing your apps and get more install via a simple banner view & native view and interstitial dialog.

An Android library for member secretGFX group, This can be used to growing your apps and get more install via a simple banner view & native view and interstitial dialog.

GFX-AdPromote An Android library for member secretGFX group, This can be used to growing your apps and get more install via a simple banner view & nat

Dec 25, 2022

Squaremap is a minimalistic and lightweight world map viewer for Minecraft servers, using the vanilla map rendering style

squaremap squaremap (formerly known as Pl3xMap) is a minimalistic and lightweight live world map viewer for Minecraft servers. What is squaremap If, l

Jan 3, 2023

Java 1-15 Parser and Abstract Syntax Tree for Java, including preview features to Java 13

JavaParser This project contains a set of libraries implementing a Java 1.0 - Java 14 Parser with advanced analysis functionalities. This includes pre

Jan 5, 2023

RTree2D is a 2D immutable R-tree with STR (Sort-Tile-Recursive) packing for ultra-fast nearest and intersection queries

RTree2D is a 2D immutable R-tree with STR (Sort-Tile-Recursive) packing for ultra-fast nearest and intersection queries

RTree2D RTree2D is a 2D immutable R-tree with STR (Sort-Tile-Recursive) packing for ultra-fast nearest and intersection queries. Goals Main our requir

Dec 14, 2022

Java 1-15 Parser and Abstract Syntax Tree for Java, including preview features to Java 13

JavaParser This project contains a set of libraries implementing a Java 1.0 - Java 14 Parser with advanced analysis functionalities. This includes pre

Jan 9, 2023

Directory tree model for JavaFX that watches the filesystem for changes.

LiveDirsFX LiveDirsFX is a combination of a directory watcher, a directory-tree model (for TreeView) and a simple asynchronous file I/O facility. The

Oct 23, 2022

Unified Device Tree for Realme X3 series

Unified Device Tree for Realme X3 series

Unified Device Tree for Realme X3 series The realme X3 (codenamed "RMX2081", "RMX2083") is a high-end smartphone from realme. It was announced and rel

May 5, 2022

[WIP] Device Tree for Redmi K30 Ultra

[WIP] Device Tree for Redmi K30 Ultra

A buildable device tree for the Redmi K30 Ultra (codenamed "cezanne") written by beginners, borrowing a lot from the RMX3031, chopin, atom and the ori

Dec 9, 2022

Device tree for Redmi K50 (rubens)

Device tree for Redmi K50 (rubens)

Copyright (C) 2022 The LineageOS Project Device tree for Redmi K50 (rubens) - Prebuilt The Redmi K50 (codenamed "rubens") is a high-end, mid-range sma

Dec 26, 2022

Log analyser / visualiser for Java HotSpot JIT compiler. Inspect inlining decisions, hot methods, bytecode, and assembly. View results in the JavaFX user interface.

JITWatch Log analyser and visualiser for the HotSpot JIT compiler. Video introduction to JITWatch video Slides from my LJC lightning talk on JITWatch

Jan 3, 2023

Log analyser / visualiser for Java HotSpot JIT compiler. Inspect inlining decisions, hot methods, bytecode, and assembly. View results in the JavaFX user interface.

JITWatch Log analyser and visualiser for the HotSpot JIT compiler. Video introduction to JITWatch video Slides from my LJC lightning talk on JITWatch

Jan 3, 2023

add one tag before or end text view

add one tag before or end text view

Tag Label Text Android Make a tag of text for android with custom background of tag Setup Coppy 2 class RoundBackgroundColorSpan.java and TagLabelText

Jan 24, 2022
Comments
  • 删除节点

    删除节点

    请问怎么删除父节点下的所有子节点,同时不要删除父节点?现在项目里的代码是删除一个父节点后把子节点和当前节点都删了,所有我通过遍历每个子节点进行删除,但是在不使用删除节点动画时可以通过便利删除每个节点(虽然可以实现删除功能但是删除后视图会抖动偏移),而当设置删除动画为true时节点会出现删不掉的bu g

    opened by MinDaren 4
  • Now Can Exactly Add or remove a node 😀

    Now Can Exactly Add or remove a node 😀

    Done Some changes in ' MainActivity.java '

    • Now You User can Directly choose To which Node he wants to delete
    • An from which node he wants to has child nodes
    • user can do this all stuff by just click on the item

    Hope It is Fine 😀

    MainActivity.zip

    opened by DarkCode462 1
  • 只有VerticalTreeLayoutManager与RightTreeLayoutManager两种布局

    只有VerticalTreeLayoutManager与RightTreeLayoutManager两种布局

    implementation 'io.github.guaishoun:gyso-treeview:1.0.1' 只有VerticalTreeLayoutManager 和 RightTreeLayoutManager 两种布局方式

    下载的里面却有好多种布局 RightTreeLayoutManager LeftTreeLayoutManager CompactRightTreeLayoutManager CompactLeftTreeLayoutManager …………………………

    opened by h79314711 1
Releases(v1.2)
Owner
怪兽N
Try a better life.
怪兽N
Directory tree model for JavaFX that watches the filesystem for changes.

LiveDirsFX LiveDirsFX is a combination of a directory watcher, a directory-tree model (for TreeView) and a simple asynchronous file I/O facility. The

Tomas Mikula 44 Oct 23, 2022
add one tag before or end text view

Tag Label Text Android Make a tag of text for android with custom background of tag Setup Coppy 2 class RoundBackgroundColorSpan.java and TagLabelText

Nguyễn Trọng Hải 15 Jan 24, 2022
TMU is very simple app for posting your digital manga as article into Telegraph for further reading using any browser or in Telegram with Instant View.

TMU is very simple app for posting your digital manga as article into Telegraph for further reading using any browser or in Telegram with Instant View. App may be very helpful for content translators that searching easy way to share their work.

null 5 Oct 6, 2022
A view for developing JavaFX stylesheets.

ShowcaseFX At least JDK 11 is required. This project contains a single control called CssShowcaseView that can be used to preview the results produced

DLSC Software & Consulting GmbH 28 Dec 23, 2022
Custom JavaFX bindings made easy with lambdas.

EasyBind EasyBind leverages lambdas to reduce boilerplate when creating custom bindings, provides a type-safe alternative to Bindings.select* methods

Tomas Mikula 146 May 29, 2022
A project that shows the different ways on how to create custom controls in JavaFX

JavaFX Custom Controls This project will show different ways on how to create custom controls in JavaFX. It will cover the following approaches: Resty

Gerrit Grunwald 27 Sep 5, 2022
Understand Server-Sent Events (SSE), analyze its principle, and implement custom SSE.

custom-sse Email:[email protected] Github:https://github.com/JorringHsiao QQ:3129600569 ?? 关键词:SSE, 服务端推送, 实时推送, 进度条 ?? 本项目的目的 以进度条的功能需求为例,引出

JorringHsiao 17 Oct 18, 2021
A small tools to play with JavaFX Color.derive() function - allows to create custom colors and to save those in color palettes.

DeriveColorsFX This is not a serious application. Its a small tool where I just played with the method Color::deriveColor provided by JavaFX. Also its

Oliver Löffler 11 Oct 9, 2022
RXControls is a JavaFX custom component library.

RXControls RXControls Version 8.x.y need javafx8 RXControls Version 11.x.y need javafx11+ 一个javafx的自定义组件库, 密码可见组件, 轮播图组件, 动态按钮组件等, 音频频谱可视化组件,歌词组件 等...

null 164 Jan 1, 2023
Tool for creating custom GUIs using packets.

Tool for creating custom GUIs using packets.

Geo3gamer 0 Feb 14, 2022