Skip to content

Commit

Permalink
Merge branch 'kotlin'
Browse files Browse the repository at this point in the history
# Conflicts:
#	README.md
#	gradle/wrapper/gradle-wrapper.properties
#	graphview/build.gradle
#	graphview/src/main/java/de/blox/graphview/Graph.java
#	graphview/src/main/java/de/blox/graphview/GraphNodeContainerView.java
#	graphview/src/main/java/de/blox/graphview/Node.java
#	graphview/src/main/java/de/blox/graphview/edgerenderer/ArrowEdgeRenderer.java
#	graphview/src/main/java/de/blox/graphview/layered/SugiyamaEdgeRenderer.java
#	sample/build.gradle
#	sample/src/main/java/de/blox/graphview/sample/GraphActivity.java
  • Loading branch information
GregorBlock committed Jul 3, 2020
2 parents b713f10 + 1529778 commit 25df569
Show file tree
Hide file tree
Showing 67 changed files with 3,112 additions and 3,942 deletions.
50 changes: 42 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,43 @@
# Built application files
*.apk
*.ap_

# Files for the ART/Dalvik VM
*.dex

# Java class files
*.class

# Generated files
bin/
gen/
out/

# Gradle files
.gradle/
build/

# Local configuration file (sdk path, etc)
local.properties

# Proguard folder generated by Eclipse
proguard/

# Log Files
*.log

# Android Studio Navigation editor temp files
.navigation/

# Android Studio captures folder
captures/

# Intellij
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.externalNativeBuild
.idea/workspace.xml

# Keystore files
*.jks

.idea
.DS_Store
6 changes: 3 additions & 3 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

90 changes: 35 additions & 55 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Download

```groovy
dependencies {
implementation 'de.blox:graphview:0.6.1'
implementation 'de.blox:graphview:0.7.0'
}
```
Layouts
Expand All @@ -32,52 +32,38 @@ Algorithm from Sugiyama et al. for drawing multilayer graphs, taking advantage o

Usage
======

Using GraphView is not much different than using RecyclerView.
Add GraphView to your layout file.
```xml
<LinearLayout
<com.otaliastudios.zoom.ZoomLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
app:hasClickableChildren="true">

<de.blox.graphview.GraphView
android:id="@+id/graph"
android:layout_width="match_parent"
android:layout_height="match_parent">
</de.blox.graphview.GraphView>
</LinearLayout>
```
You can make the node Layout how you like. Just define a layout file, e.g. ```node.xml``` ...
```xml
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="5dp"
card_view:cardBackgroundColor="@android:color/holo_blue_dark"
card_view:cardElevation="16dp"
card_view:contentPadding="10dp">

<LinearLayout
android:id="@+id/graph"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
app:lineColor="@android:color/holo_blue_dark"
app:lineThickness="2dp"
app:useMaxSize="true" />
</com.otaliastudios.zoom.ZoomLayout>
```

<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@android:color/white"
android:textStyle="bold"/>
Currently GraphView must be used together with a Zoom Engine like [ZoomLayout](https://github.com/natario1/ZoomLayout). To change the zoom values just use the different attributes described in the ZoomLayout project site.

</LinearLayout>
</android.support.v7.widget.CardView>
Then define the node layout, e.g. ```node.xml```. You can make the node Layout as complex as you want.
```xml
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
```

... and use it with the adapter
To create a graph, we need to instantiate the `Graph` class. Next bind your graph to GraphView, for that you must extend from the `GraphView.Adapter` class.

```java
public class MainActivity extends AppCompatActivity {
private int nodeCount = 1;
public class GraphActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -87,26 +73,26 @@ public class MainActivity extends AppCompatActivity {

// example tree
final Graph graph = new Graph();
final Node node1 = new Node(getNodeText());
final Node node2 = new Node(getNodeText());
final Node node3 = new Node(getNodeText());
final Node node1 = new Node("Parent");
final Node node2 = new Node("Child 1");
final Node node3 = new Node("Child 2");

graph.addEdge(node1, node2);
graph.addEdge(node1, node3);

// you can set the graph via the constructor or use the adapter.setGraph(Graph) method
final BaseGraphAdapter<ViewHolder> adapter = new BaseGraphAdapter<ViewHolder>(graph) {
adapter = new GraphAdapter<GraphView.ViewHolder>(graph) {

@NonNull
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
public GraphView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
final View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.node, parent, false);
return new SimpleViewHolder(view);
}

@Override
public void onBindViewHolder(ViewHolder viewHolder, Object data, int position) {
((SimpleViewHolder)viewHolder).textView.setText(data.toString());
public void onBindViewHolder(GraphView.ViewHolder viewHolder, Object data, int position) {
((SimpleViewHolder) viewHolder).textView.setText(data.toString());
}
};
graphView.setAdapter(adapter);
Expand All @@ -118,23 +104,19 @@ public class MainActivity extends AppCompatActivity {
.setSubtreeSeparation(300)
.setOrientation(BuchheimWalkerConfiguration.ORIENTATION_TOP_BOTTOM)
.build();
adapter.setAlgorithm(new BuchheimWalkerAlgorithm(configuration));
}

private String getNodeText() {
return "Node " + nodeCount++;
adapter.setLayout(new BuchheimWalkerAlgorithm(configuration));
}
}
```

Your ViewHolder class should extend from ViewHolder:
Your ViewHolder class should extend from `GraphView.ViewHolder`:
```java
class SimpleViewHolder extends ViewHolder {
class SimpleViewHolder extends GraphView.ViewHolder {
TextView textView;

SimpleViewHolder(View itemView) {
super(itemView);
textView = itemView.findViewById(R.id.textView);
textView = itemView.findViewById(R.id.text);
}
}
```
Expand All @@ -153,8 +135,6 @@ To use the custom attributes you have to add the namespace first: ```

Each of the attributes has a corresponding setter in the GraphView class, if you want to use it programmatically.

GraphView internally uses [ZoomLayout](https://github.com/natario1/ZoomLayout) for its zoom feature. To change the zoom values just use the different attributes described in the ZoomLayout project site.

Examples
========
#### Rooted Tree
Expand All @@ -169,7 +149,7 @@ Examples
License
=======

Copyright 2019 Team-Blox
Copyright 2020 Team-Blox

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.3.72'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.1'
classpath 'com.android.tools.build:gradle:4.0.0'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m

# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# org.gradle.parallel=true
android.useAndroidX=true
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Sep 26 15:16:58 CEST 2018
#Wed Jul 01 14:28:22 CEST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
15 changes: 8 additions & 7 deletions graphview/build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

android {
compileSdkVersion 27
compileSdkVersion 29

defaultConfig {
minSdkVersion 16
targetSdkVersion 27
targetSdkVersion 29
versionCode 1
versionName "1.0"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

}
buildTypes {
Expand All @@ -27,9 +28,9 @@ android {

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.annimon:stream:1.2.1'
api 'com.otaliastudios:zoomlayout:1.7.0'
implementation "androidx.appcompat:appcompat:1.1.0"
implementation "androidx.annotation:annotation:1.1.0"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
}

ext {
Expand All @@ -45,7 +46,7 @@ ext {
siteUrl = "https://github.com/Team-Blox/GraphView"
gitUrl = "https://github.com/Team-Blox/GraphView.git"

libraryVersion = '0.6.1'
libraryVersion = '0.7.0'

developerId = 'Team-Blox'
developerName = 'Blox'
Expand Down
16 changes: 0 additions & 16 deletions graphview/src/main/java/de/blox/graphview/Algorithm.java

This file was deleted.

Loading

0 comments on commit 25df569

Please sign in to comment.