Comments (5)
可以增加完整导图截图功能和导出文本功能
文本功能如下:
地球 海洋 北冰洋 大西洋 太平洋 陆地 亚洲 欧洲
如果作为一个通用的结构图控件,这方面你有具体的方案没有?比如json、xml...,一般用法有哪些?
因为我之前项目没有做复杂功能,编辑功能都是应别人请求做的
from android-thinkmap-treeview.
我是试了序列化对象再转成hex string,这样app容易序列化与反序列化,但如果离开app,就只能导致出文本格式了,方便用户看文本。试过NodeModel导成Gson,会FC
编辑功能是有必要的
from android-thinkmap-treeview.
我试过截view图,但文字比较小还有只有某个区域,得做区域截图并做全域滚动,再把图拼接。导出图片也是一种格式导出
from android-thinkmap-treeview.
生成截图的功能我这边已经实现,可以参考:
/**
* 加载静态xml布局资源生成Bitmap
*
* @param context
* @param layoutRes xml 布局资源ID
* @param onInitCallBack 数据初始化回调
*/
fun convertViewToBitmap(
context: Context,
@LayoutRes layoutRes: Int,
onInitCallBack: (View)-> Unit
): Bitmap {
val root = LayoutInflater.from(context).inflate(layoutRes, null)
onInitCallBack(root)
//测量
val width = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED)
val height = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED)
root.measure(width, height)
val measuredWidth = root.measuredWidth
val measuredHeight = root.measuredHeight
//再次测量(避免子View无法正常显示)
root.measure(View.MeasureSpec.makeMeasureSpec(measuredWidth, View.MeasureSpec.EXACTLY), View.MeasureSpec.makeMeasureSpec(measuredHeight, View.MeasureSpec.EXACTLY))
//布局
root.layout(0, 0, measuredWidth, measuredHeight)
val bitmap = Bitmap.createBitmap(measuredWidth, measuredHeight, Bitmap.Config.ARGB_8888)
val canvas = Canvas(bitmap)
root.draw(canvas)
return bitmap
}
val bitmap =
BitmapUtils.convertViewToBitmap(activity,
R.layout.save_xmind_layout) { rootView ->
val gysoTreeView =
rootView.findViewById<GysoTreeView>(
R.id.tree_view)
val saveAdapter =
XMindTreeViewAdapter()
gysoTreeView.adapter = saveAdapter
gysoTreeView.setTreeLayoutManager(
getTreeLayoutManager())
saveAdapter.treeModel =
adapter.treeModel
saveAdapter.bindBaseTreeView(
gysoTreeView)
saveAdapter.getTreeViewEditor()
.focusMidLocation(false)
}
目前还有给棘手的问题就是,如何把数据存储起来,序列化会直接报错,这比较麻烦,不知道大家有什么好办法没?
from android-thinkmap-treeview.
public static String writeTreeObject(Object object) throws Exception {
ByteArrayOutputStream out = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(out);
oos.writeObject(object);
oos.close();
ByteString byteString = ByteString.of(out.toByteArray(),0,out.size());
return byteString.hex();
}
public static Object readTreeObject(String hex) throws Exception {
ByteArrayInputStream in=new ByteArrayInputStream(ByteString.decodeHex(hex).toByteArray());
ObjectInputStream oin = new ObjectInputStream(in);
Object obj = oin.readObject();
oin.close();
return obj;
}
from android-thinkmap-treeview.
Related Issues (20)
- 请问怎么调节两个同级节点间的距离,不使用统一设定的值
- 麻烦作者增加导出导入json功能 HOT 2
- 关于节点的收起和展开功能 HOT 3
- 如何定位到某个节点 HOT 1
- ios equavilent HOT 2
- 节点之间上下级关系只能通过 addNode(root, child1,child2....)这个方法来绑定吗? HOT 1
- 在
- 能修改上下的间距吗 HOT 3
- 可以添加一个将几个结点视作一个结点的方法吗 HOT 1
- 位置重叠
- 给的 demo 没有 NodeBaseLayoutBinding HOT 1
- 可以有多个root节点吗 HOT 1
- 只有VerticalTreeLayoutManager与RightTreeLayoutManager两种布局 HOT 1
- 这个能设置初始的缩放比例吗?
- 数据无法保存 HOT 3
- 作者有遇见会让studio的xml卡顿吗? HOT 2
- 点击不同的item能进行不同的跳转
- 感谢作者!目前Android方面最好的导图框架了。
- 请问可以在compose中使用么? HOT 2
- 版本问题 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from android-thinkmap-treeview.