android-network-graph
Description
Network graph based on :
Here's a screenshot :
## Usage
repositories {
jcenter()
}
dependencies {
compile 'org.giwi:android-network-graph:0.0.1'
}
<giwi.org.networkgraph.GraphSurfaceView
android:id="@+id/mysurface"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
app:nodeBgColor="@android:color/white"
app:defaultColor="@android:color/black"
app:edgeColor="@android:color/holo_blue_light"
app:nodeColor="@android:color/holo_blue_light"
android:layout_margin="10dp"/>
Node v1 = new SimpleNode("18");
Node v2 = new SimpleNode("24");
graph.getVertex().add(new Vertex(v1, ContextCompat.getDrawable(this, R.drawable.avatar)));
graph.getVertex().add(new Vertex(v2, ContextCompat.getDrawable(this, R.drawable.avatar)));
graph.addEdge(new SimpleEdge(v1, v2, "12"));
Node v3 = new SimpleNode("7");
graph.getVertex().add(new Vertex(v3, ContextCompat.getDrawable(this, R.drawable.avatar)));
graph.addEdge(new SimpleEdge(v2, v3, "23"));
v1 = new SimpleNode("14");
graph.getVertex().add(new Vertex(v1, ContextCompat.getDrawable(this, R.drawable.avatar)));
graph.addEdge(new SimpleEdge(v3, v1, "34"));
v1 = new SimpleNode("10");
graph.getVertex().add(new Vertex(v1, ContextCompat.getDrawable(this, R.drawable.avatar)));
graph.addEdge(new SimpleEdge(v3, v1, "35"));
v1 = new SimpleNode("11");
graph.getVertex().add(new Vertex(v1, ContextCompat.getDrawable(this, R.drawable.avatar)));
graph.addEdge(new SimpleEdge(v1, v3, "36"));
graph.addEdge(new SimpleEdge(v3, v1, "6"));
GraphSurfaceView surface = (GraphSurfaceView) findViewById(R.id.mysurface);
surface.init(graph);
Setting colors programmatically
graph.setDefaultColor(ContextCompat.getColor(this, android.R.color.black));
graph.setEdgeColor(ContextCompat.getColor(this, android.R.color.holo_blue_light));
graph.setNodeColor(ContextCompat.getColor(this, android.R.color.holo_blue_light));
graph.setNodeBgColor(ContextCompat.getColor(this, android.R.color.white));