java java在控制台中绘制图形或树
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14600633/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
java drawing graphs or trees in console
提问by Benj
Does anyone know a mean to "render" plots or at least trees in console mode (draw it in the console)?
有谁知道在控制台模式下“渲染”图或至少是树(在控制台中绘制)的意思吗?
I would be able to render small plots at end of a very long process, by drawing some figures in ASCII mode, in order to have a geeky & fun view of some stats collected into the process.
我将能够在一个很长的过程结束时渲染小图,通过以 ASCII 模式绘制一些图形,以便对收集到过程中的一些统计数据有一个极客和有趣的视图。
I would be pleased to discover a library which does that, and I would keep the process 100% java, no shell-hack or third-party software.
我会很高兴发现一个可以做到这一点的库,并且我会保持进程 100% java,没有 shell-hack 或第三方软件。
-- EDIT
- 编辑
@lbalazscs and @Fortega made interesting answers, but the background of my question is to know if it existssuch a library, and I will add some details I missed the first time :
@lbalazscs 和@Fortega 给出了有趣的答案,但我的问题的背景是要知道是否存在这样的库,我将添加一些我第一次错过的细节:
The output should be able to display trees, binary trees (linked by @lbalazscs here), but alsosimple graphs such as bargraphs or so.
输出应该能够显示树、二叉树(由 @lbalazscs 在这里链接),以及简单的图形,例如条形图等。
I will let this question "unanswered" for a while, and if there is no probant answer, @lbalazscs will get the point ;)
我会让这个问题“悬而未决”一段时间,如果没有明确的答案,@lbalazscs 就会明白这一点;)
采纳答案by lbalazscs
You can print ascii trees with minimal code. See the second answer to this question: How to print binary tree diagram?
您可以用最少的代码打印 ascii 树。请参阅此问题的第二个答案:如何打印二叉树图?
(the second answer because this one is not only for binary trees)
(第二个答案,因为这不仅适用于二叉树)