如何JFreeChart在不断更新的时间序列中仅显示最新数据?
附录:此处显示了一个包含已接受答案的完整,有效的示例.另见具有两个系列的该变体.另见本Q&A有关setTimeBase().
请注意我还没有在Mac机器上的Windows机器上测试过这个.我不太确定这是否也出现在Windows机器上......
当我调整Java应用程序的大小时,内容是不可见的.我已经找到一种方法来解决它后调整其大小,但不能同时在用户调整窗口的大小.
我没有使用Swing或其他东西,因为它使我的二进制文件变得如此缓慢(在我看来).
结构是这样的:
Frame 我的主窗口Container内容视图main-windowContainer基于paint(Graphics g)-method 的子视图我已经添加了所有监听器My main-window,现在我可以在调整窗口大小后重绘Content-view .
public void componentResized(ComponentEvent e) {
this.contentView.paint(this.contentView.getGraphics());
}
Run Code Online (Sandbox Code Playgroud)
我谨慎使用paint(getGraphics())-method并不是一个非常好的方法,但是因为repaint()-method根本没有做任何事情,所以它是唯一可行的方法.
调整大小时,所有绘制的内容都变得不可见.但是,当我向我添加Button-instance Content-view并调整我Main-window的大小时,该按钮不会被隐藏.
我是能够追踪"live'调整大小事件:
public void componentMoved(ComponentEvent e) {
System.out.println("Live-resize");
}
Run Code Online (Sandbox Code Playgroud)
当我将repaint-method(或官方重绘方法)添加到像这样的'live'-resize事件时,我仍然得到输出,但是,它没有重新绘制或者某些东西
public void componentMoved(ComponentEvent e) {
System.out.println("Live-resize");
this.contentView.paint(this.contentView.getGraphics());
}
Run Code Online (Sandbox Code Playgroud)
要么
public void componentMoved(ComponentEvent e) {
System.out.println("Live-resize");
this.contentView.repaint();
} …Run Code Online (Sandbox Code Playgroud)