「java动态曲线」java动态效果

博主:adminadmin 2023-03-18 17:21:05 586

本篇文章给大家谈谈java动态曲线,以及java动态效果对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。

本文目录一览:

java如何绘制类似任务管理器的动态曲线图

JDK 里面已经提供了一个现成的 DEMO,你可以在路径 JDK安装位置\demo\jfc\Java2D\Java2Demo.jar 这个 Java2D 演示示例中看到相应的内容(第二个名为Arcs_Curves的选项卡右下角就有一具内存监视器,就是类似任务管理器那个动态监视图表的效果)。

jfreechart怎么实现动态曲线图

创建eclipse工程,引入jcommon-*.jar,jfreechart-*.jar

MemoryUsage的源码可以在下面的打包文件里找到

将这个demo运行起来你就可以看到一个JVM 内存消耗的实时数据显示

分析源码后可以发现生成这样的图表主要用到了

org.jfree.data.time.TimeSeriesCollection

org.jfree.data.time.TimeSeries

这个主要的功能是实时的收集数据,API文档是这样描述的

A collection of time series objects.

This class implements the XYDataset interface,

as well as the extended IntervalXYDataset interface.

This makes it a convenient dataset for use with the XYPlot class.

org.jfree.chart.plot.XYPlot

是一个曲线图,通过指定XY的坐标来表示数据点,任何实现了XYDataset接口的类都可以通过它来显示,

它通过XYItemRenderer来设置点数据的显示样式,从而生成各种不同的图表。

A general class for plotting data in the form of (x, y) pairs.

This plot can use data from any class that implements the XYDataset interface.

XYPlot makes use of an XYItemRenderer to draw each point on the plot.

By using different renderers, various chart types can be produced.

问题

现在X轴是以时间线来显示的,可以设置以刻度或次序(1,2,3,4…)的格式显示吗?

可以,

org.jfree.data.time.TimeSeries

org.jfree.data.time.TimeSeriesCollection

换成

org.jfree.data.xy.XYSeries

org.jfree.data.xy.XYSeriesCollection

就可以了。

那他们还是动态的图吗?

是的。

那是为什么呢?

因为XYSeriesColl ection 和 TimeSeriesCollection都实现了这样一个接口

org.jfree.data.general.SeriesChangeListener

它继承自EventListener

SeriesChangeListener extends java.util.EventListener

它有定义了数据更改时发出通知的方法

Methods for receiving notification of changes to a data series.

void seriesChanged(SeriesChangeEvent event)

Called when an observed series changes in some way.

实现了这个接口的SeriesCollection都可以实时的更新数据

添加数据可以使用

series.add(X,Y);

更新可以使用

series.update(X,Y);

还有清空之前的所有数据可以使用

series.clear();

如何实时的显示特定点的数据呢?

当然JfreeChart有一个tip的功能,当鼠标移上去的时候显示数据点的数据

但是如何让它按照我们想要的格式显示呢?

这里你就需要使用

org.jfree.chart.annotations.XYTextAnnotation

A text annotation that can be placed at a particular (x, y) location on an XYPlot.

这里有一小段的代码(更多的jfreechart的demo代码可以在附件里找到,相信看过之后,基本上都能满足你的要求了)

XYTextAnnotation textpointer = new XYTextAnnotation(X+”,”+Y, X+15, Y-15);

textpointer.setBackgroundPaint(Color.YELLOW);

textpointer.setPaint(Color.CYAN);

dynamicJfreeChart.getXYPlot().addAnnotation(textpointer);

下面的代码未整理,收集来源于网络

java中 jfreechart 如何从数据库中读取数据,显示的时候作为一个动态的曲线图展示出来,这个要如何实现?

jfreechart有获取后台的数据源属性,你后台将数据查询出来就可以了。关于曲线图的生成jfreechart肯定有自动封装的!调用就可以。

Java有没有绘制实时动态曲线图的控件

第一用第三方控件,可以实现Winfrom 图标控件里面有这个,可以实现 第二 用GDI+绘制 需自己的写代码和实现

关于java动态曲线和java动态效果的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。