quatja / vorolay Goto Github PK
View Code? Open in Web Editor NEWVoronoiView is a view (ViewGroup) that allows you to add and display views inside Voronoi diagram regions.
License: Apache License 2.0
VoronoiView is a view (ViewGroup) that allows you to add and display views inside Voronoi diagram regions.
License: Apache License 2.0
Hey, first of all I would like to say this is an amazing library :)
Is there a way to make it not random? as in the same picture will go to the same spot with the exact same shape every time? Even when playing with generation_type and setGenerationType it still adds random shapes
Not sure what's going on here but I keep getting this error
which refers to this part of the library
This is my adapter for the listview
package com.example.frido.rando.Utilities;
import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.example.frido.rando.R;
import java.io.File;
import java.util.ArrayList;
import java.util.Random;
import butterknife.BindView;
import butterknife.ButterKnife;
import quatja.com.vorolay.VoronoiView;
public class VoronoAdapter extends BaseAdapter {
private Context context;
private LayoutInflater layoutInflater;
private ArrayList<String> imageURLs;
private File filePath;
public VoronoAdapter(ArrayList<String> imageURLs, Context context) {
this.imageURLs = imageURLs;
this.context = context;
this.layoutInflater = LayoutInflater.from(context);
}
@Override
public int getCount() {
return imageURLs.size();
}
@Override
public Object getItem(int position) {
return imageURLs.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
convertView = layoutInflater.inflate(R.layout.vorono_template, parent, false);
holder = new ViewHolder(convertView);
convertView.setTag(holder);
for (int i = 0; i < 20; i++) {
View view = layoutInflater.inflate(R.layout.vorono_item_for_template, null, false);
holder.voronoi.addView(view);
ImageView layout = (ImageView) view.findViewById(R.id.itemVoronoLayout);
Random rnd = new Random();
int color = Color.argb(255, rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256));
layout.setBackgroundColor(color);
}
} else {
holder = (ViewHolder) convertView.getTag();
}
return convertView;
}
static class ViewHolder{
@BindView(R.id.voronoTemplateForList) VoronoiView voronoi;
public ViewHolder(View view){
ButterKnife.bind(this,view);
}
}
}
```
`
My code:
voronoiView = (VoronoiView) findViewById(R.id.voronoi); LayoutInflater layoutInflater = getLayoutInflater(); for (int i = 0; i < 15; i++) { ImageView view = (ImageView) layoutInflater.inflate(R.layout.item_iv, null, false); view.setImageResource(R.drawable.p2_480); voronoiView.addView(view); }
app works correctly on emulator with API24, but is not properly cropped on an API19 (android 4.2.2) device.
the code for adding the view is
for (int i = 0; i < count; i++) {
RelativeLayout rl = (RelativeLayout) layoutInflater.inflate(R.layout.item_voronoi, null, false);
ImageView view = ( ImageView) rl.findViewById(R.id.image);
view.setImageURI(uri);
vv.addView(rl);
}
and the xml is
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop" />
</RelativeLayout>
Hey I've been trying to use your library but when I add it to my layout I get this error
java.lang.NullPointerException
at quatja.com.vorolay.diagram.Voronoi.addCornerEdges(Voronoi.java:167)
at quatja.com.vorolay.diagram.Voronoi.getRegions(Voronoi.java:131)
at quatja.com.vorolay.VoronoiView.generateDiagram(VoronoiView.java:428)
at quatja.com.vorolay.VoronoiView.onSizeChanged(VoronoiView.java:321)
at android.view.View.sizeChange(View.java:17638)
at android.view.View.setFrame(View.java:17600)
at android.view.View.layout(View.java:17517)
at android.view.ViewGroup.layout(ViewGroup.java:5612)
at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1079)
at android.view.View.layout(View.java:17520)
at android.view.ViewGroup.layout(ViewGroup.java:5612)
at android.support.design.widget.HeaderScrollingViewBehavior.layoutChild(HeaderScrollingViewBehavior.java:131)
at android.support.design.widget.ViewOffsetBehavior.onLayoutChild(ViewOffsetBehavior.java:42)
at android.support.design.widget.AppBarLayout$ScrollingViewBehavior.onLayoutChild(AppBarLayout.java:1375)
at android.support.design.widget.CoordinatorLayout.onLayout_Original(CoordinatorLayout.java:870)
at android.support.design.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java)
at android.view.View.layout(View.java:17520)
at android.view.ViewGroup.layout(ViewGroup.java:5612)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at android.view.View.layout(View.java:17520)
at android.view.ViewGroup.layout(ViewGroup.java:5612)
at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1079)
at android.view.View.layout(View.java:17520)
at android.view.ViewGroup.layout(ViewGroup.java:5612)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:345)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:429)
at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:389)
at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:548)
at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:533)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:966)
at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:533)
at com.android.tools.idea.rendering.RenderTask.lambda$inflate$70(RenderTask.java:659)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
I set up a clickListener for the views in the vorolay layout. When I click a region on an imageView that's "overlapped" by another, the other imageView is activated (see attached image).
is there any settings I can configure?
the following are my codes
for (int i = 0; i < count; i++) {
RelativeLayout rl = (RelativeLayout) layoutInflater.inflate(R.layout.item_voronoi, null, false);
ImageView iv = ( ImageView) rl.findViewById(R.id.image);
//add a callback when the image is clicked
int value = i;
iv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Log.d("TEST", "item clicked: "+ value);
}
});
loadImage(iv, uri); //this method populates the image
vv.addView(rl); //this is the VoronoiView
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.