JFreeChart CombinedDomainXYPlot-维持绘图顺序 [英] JFreeChart combinedDomainXYPlot - maintaining order of plots

查看:31
本文介绍了JFreeChart CombinedDomainXYPlot-维持绘图顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在combinedDomainXYPlot中隐藏/显示图,但是该类仅允许添加/删除图.例如,如果我有3个图,则删除第二个图,然后添加它,从视觉上看,它将添加为底部的第三个图.有什么办法可以直观地保持图表的顺序?

I would like to hide/show plots in combinedDomainXYPlot but the class only allows to add/remove plots. For instance, if I have 3 plots, I remove the second, and then add it, visually it is going to add it as the third chart at the bottom. Is there any way to maintain the charts order visually?

推荐答案

我将使用 ListSelectionModel ,这两个 JList 都可以使用,显示为此处.前者具有灵活的布局,而后者具有便捷的 JCheckbox 渲染器/编辑器.

I'd use a ListSelectionModel, which is available to both JList, shown here, and JTable, shown here. The former has a flexible layout, while the latter has a convenient JCheckbox renderer/editor.

让我们假设您的模型最终生成了一个名为 selected List< Plot> .您可以遍历 getSubplots()列表以 remove()所有当前图,然后遍历 List< Plot> add()返回每个选定的图.

Lets assume your model ultimately produces a List<Plot> named selected. You can loop though the getSubplots() list to remove() all current plots, then loop through your List<Plot> to add() each selected plot back.

附录:如果子图相同,则可以 add() remove()最小数量的子图并替换那些模型在此处中显示的仍使用 setDataset()的代码.它稍微复杂些,但视觉上的破坏性可能较小.

Addendum: If the subplots are otherwise identical, you may be able to to add() or remove() a minimum number of subplots and replace the models of those that remain using setDataset(), shown here. It's slightly more complicated but perhaps less visually disruptive.

这篇关于JFreeChart CombinedDomainXYPlot-维持绘图顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆