misakuo / 3dtagcloudandroid Goto Github PK
View Code? Open in Web Editor NEWTagcloud component for android
License: MIT License
Tagcloud component for android
License: MIT License
It is not possible to set white as dark or light tag text color.
When I set #ffffff as darkColor or lightColor the text color of the tag cloud is always shown black.
Also when I set a grey color tone e.g. #63696b the result is a yellow tone.
https://sites.google.com/site/tagindemo/TagCloud
I failed in tagindemo 2 years ago...
细看的话,文字有一些抖动,请问有什么方法可以优化吗?
How to change color of each tag?
如题,考虑可能是子View的Z轴排列问题,我自己fork之后做了修改,目前我的解决办法是在TagCloudView
的onLayout
中用child.bringToFront();
控制Z轴排序。但可能性能上会有问题,希望能有更好的解决方法:)
TagCloudView
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
left = l;
right = r;
top = t;
bottom = b;
Collections.sort(tags, new SortByScale());
for (int i=0;i<tags.size();i++){
Tag tag=tags.get(i);
View child =tag.getChildView();
if (child!=null&&child.getVisibility() != GONE) {
child.setScaleX(tag.getScale());
child.setScaleY(tag.getScale());
child.setAlpha(tag.getAlpha());
int left, top;
left = (int) (centerX + tag.getLoc2DX()) - child.getMeasuredWidth() / 2;
top = (int) (centerY + tag.getLoc2DY()) - child.getMeasuredHeight() / 2;
child.layout(left, top, left + child.getMeasuredWidth(), top + child.getMeasuredHeight());
child.bringToFront();
}
}
SortByScale
class SortByScale implements Comparator {
public int compare(Object o1, Object o2) {
if(o1 instanceof Tag && o2 instanceof Tag){
return ((Tag) o1).getScale()>((Tag) o2).getScale()?1:-1;
}
return 0;
}
}
主线程更新TagCloudView出现较多jank,可以尝试使用单独的非主线程进行维护进行优化,但是目前的TagClouldView限制了更新线程只能在主线程
解决方案:https://github.com/misakuo/3dTagCloudAndroid/pull/33/commits
如下方法可以自定义一个线程,并在线程中维护TagCloudView
//: MyThread.java
@Override
public void run() {
Looper.prepare();
mHandler = new Handler(Looper.myLooper());
WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(
WindowManager.LayoutParams.MATCH_PARENT, Utils.dx2dp(400),
TYPE_APPLICATION, 0, PixelFormat.TRANSPARENT);
layoutParams.gravity = Gravity.TOP;
layoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
mWindowManager.addView(mFrameLayout = new FrameLayout(mContext),
layoutParams
);
mFrameLayout.setVisibility(View.GONE);
onViewCreated(mFrameLayout);
Looper.loop();
}
private void onViewCreated(FrameLayout frameLayout) {
frameLayout.setVisibility(View.VISIBLE);
if (frameLayout.getChildCount() == 0){
LayoutInflater.from(mContext.getApplicationContext())
.inflate(R.layout.layout_planet, frameLayout);
}
frameLayout.setVisibility(View.VISIBLE);
initCloudView(frameLayout);
}
private void initCloudView(FrameLayout frameLayout) {
if (frameLayout.getParent() == null ) return;
TagCloudView tagCloudView = frameLayout.findViewById(R.id.tag_cloud);
try {
Field handler = tagCloudView.getClass().getDeclaredField("handler");
handler.setAccessible(true);
handler.set(tagCloudView, new Handler(Looper.myLooper()));
} catch (Exception e) {
e.printStackTrace();
}
TagCloudAdapter adapter = new TagCloudAdapter();
tagCloudView.setAdapter(adapter);
}
位运算的乘法运算一直搞不懂,请教一下,谢谢
手按下拖动,拖动效果流畅。当拖动一下段距离后,放开手指,view感觉明显卡顿。
请问一下,我如如何在这个球形中间放一个头像,且旋转的时候不会触碰头像范围
按照demo的代码在Fragment中使用会报NullPointerException:java.lang.NullPointerException: Attempt to invoke virtual method 'int com.moxun.tagcloudlib.view.TagsAdapter.getCount()' on a null object reference
因设计上的需求,我在切换数据源的时候,出现跳屏的问题
最近使用了MODE_DECELERATE
模式
在TagCloudView.java
中的line384行似乎有个小bug
@Override
public void run() {
if (!isOnTouch && mode != MODE_DISABLE) {
if (mode == MODE_DECELERATE) {
if (mAngleX > 0.04f) {
mAngleX -= 0.02f;
}
if (mAngleY > 0.04f) {
mAngleY -= 0.02f;
}
if (mAngleX < -0.04f) {
mAngleX += 0.02f;
}
if (mAngleY < 0.04f) {
mAngleY += 0.02f;
}
}
processTouch();
}
handler.postDelayed(this, 50);
}
mAngleY < 0.04f
这里似乎应为mAngleY < -0.04f
否则会出现手势结束后y轴最后回归相反方向运动的状态
另外,0.04的界定值似乎略微小,会停住不动,希望可以提供属性扩展或略微调高,thx~
将SIMPLE TEXT TAG和CUSTOM VIEW TAG多次切换后程序奔溃,日志显示空指针异常
FATAL EXCEPTION: main Process: com.moxun.tagcloud, PID: 20838 java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.View.setBackgroundColor(int)' on a null object reference at com.moxun.tagcloud.ViewTagsAdapter.onThemeColorChanged(ViewTagsAdapter.java:38) at com.moxun.tagcloudlib.view.TagCloudView.onLayout(TagCloudView.java:282) at android.view.View.layout(View.java:15697) at android.view.ViewGroup.layout(ViewGroup.java:5050) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1703) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1557) at android.widget.LinearLayout.onLayout(LinearLayout.java:1466) at android.view.View.layout(View.java:15697) at android.view.ViewGroup.layout(ViewGroup.java:5050)
原因是ViewTagsAdapter中onThemeColorChanged方法未做判空过滤。
我设置滚动速度后,星球自行滚动的速度还是没有变化
大神你好,你这个容器真的很棒,但我从它的规律上看他是从两头螺旋向上的,如果想要它变成经纬分明的(只有经度,或者纬度),每个view的方向面向球心,有什么好的思路吗?
另外,如果第一步能实现,可否支持这样一个方法addView(int x,int y,int z);x代表指南针角度(0-360),y代表俯仰角度,z代表左右角度。
实际上我一直在研究这件事😑
这个Adapter啥都没干,有什么意义啊
标签设置点击事件和手势滑动球体事件冲突,可以解决并加上此功能吗。不胜感谢。
使用setOnTagClickListener()点击事件是正常的, 但直接在子布局的view上添加点击事件,会出现,点击无效的情况, 具体表现是,偶尔点击无效,拖动布局转一转,就又可以点击了
在计算关键的phi和theta值得算法里:
phi = Math.acos(-1.0 + (2.0 * i - 1.0) / count);
theta = Math.sqrt(count * Math.PI) * phi;
其中phi的我能理解,但是theta为什么是这么计算的呢?求教,查了很多资料,比如:
https://www.cnblogs.com/dishuostec/archive/2011/10/25/2223703.html
都没有给出准确解答
第一个数据坐标固定不动,点击其他数据滚动到第一条数据位置,带上滚动效果,这种如何实现?
如题,应该怎么设置才能不会被切?
Use test activity from test apk. Click buttons "simple text tag", "custom view tag", "vectordrawable tag". Somtime crash all adapters.
Log:
10-12 09:06:32.902 673 1227 I ActivityManager: Process com.moxun.tagcloud (pid 20872) has died
10-12 09:06:36.785 673 1226 I ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10100000 pkg=com.moxun.tagcloud cmp=com.moxun.tagcloud/.MainActivity bnds=[52,599][667,1214]} from uid 10100 on display 0
10-12 09:06:36.845 673 794 I ActivityManager: Start proc com.moxun.tagcloud for activity com.moxun.tagcloud/.MainActivity: pid=20916 uid=10230 gids={50230, 9997} abi=x86
10-12 09:07:12.832 20916 20916 E AndroidRuntime: Process: com.moxun.tagcloud, PID: 20916
10-12 09:07:12.832 20916 20916 E AndroidRuntime: at com.moxun.tagcloud.TextTagsAdapter.onThemeColorChanged(TextTagsAdapter.java:62)
10-12 09:07:12.832 20916 20916 E AndroidRuntime: at com.moxun.tagcloudlib.view.TagCloudView.onLayout(TagCloudView.java:270)
10-12 09:07:12.832 20916 20916 E AndroidRuntime: at com.moxun.tagcloudlib.view.TagCloudView.updateChild(TagCloudView.java:256)
10-12 09:07:12.832 20916 20916 E AndroidRuntime: at com.moxun.tagcloudlib.view.TagCloudView.processTouch(TagCloudView.java:351)
10-12 09:07:12.832 20916 20916 E AndroidRuntime: at com.moxun.tagcloudlib.view.TagCloudView.run(TagCloudView.java:376)
10-12 09:07:12.835 673 688 W ActivityManager: Force finishing activity com.moxun.tagcloud/.MainActivity
10-12 09:07:13.365 673 697 W ActivityManager: Activity pause timeout for ActivityRecord{26d98e4b u0 com.moxun.tagcloud/.MainActivity t35188 f}
10-12 09:07:14.775 673 722 W InputDispatcher: channel '1fb4c40 com.moxun.tagcloud/com.moxun.tagcloud.MainActivity (server)' ~ Consumer closed input channel or an error occurred. events=0x9
如果需要一个椭圆该如何处理 请教
用颜色深浅或者适度的大小区别,来区分词频
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.