【问题标题】:LineChart JavaFX PerformanceLineChart JavaFX 性能
【发布时间】:2017-06-16 01:38:04
【问题描述】:

Raspian - Raspberry Pi 上的 LineChart 的响应速度比正常速度慢。我正在编写示波器并不断重绘 2 个系列,每组 500 个点(总共 1000 个点)。动画已关闭。数据收集是高性能的(低于 2 毫秒)。当前数据重绘时间为800 ms左右。所需的重绘时间至少为 100 毫秒。我在下面包含了代码 sn-ps。在树莓派上显示高性能 javafx 图表的最佳实践是什么?我采取了错误的方法吗?我应该使用不同类型的图表来连续重绘两条线吗?

平台:

  • 树莓派 v. 3
    • 操作系统:Raspian 版本 8 (jessie)
    • Java 版本:
      • java版本“1.8.0_65”
      • Java(TM) SE 运行时环境(内部版本 1.8.0_65-b17)
      • Java HotSpot(TM) 客户端虚拟机(内部版本 25.65-b01,混合模式)
    • JavaFX 版本:armv6hf-sdk 8.0.102(构建 b00)
    • 内存分割:512 MB 图形,512 MB 系统
    • 视频:HDMI
    • SoC:博通 BCM2837
    • CPU:4×ARM Cortex-A53,1.2GHz

显示代码

@FXML
LineChart oscilloscope;

//indicates that the previous data has been displayed
//and that the latest data should now be displayed
//didn't bother to synchronize
boolean needsUpdating = true;

protected void startDisplay() {
    oscilloscope.setAnimated(false);
    oscilloscope.setCreateSymbols(false);
    oscilloscope.getXAxis().setLabel("Time (ms)");
    oscilloscope.getXAxis().setAutoRanging(false);
    oscilloscope.getYAxis().setLabel("Volts (v)");
    oscilloscope.getYAxis().setAutoRanging(false);

    new Thread() {
        public void run() {
             while (!done) {
               XYChart.Series ch1 = getChan1Data();
               XYChart.Series ch2 = getChan2Data();
               ch1.setName("Channel 1");
               ch2.setName("Channel 2");

              if (needsUpdated) {
                  needsUpdated = false;
                  Platform.runLater(new Runnable() {
                      @Override
                      public void run() {
                           //performance is the same whether I use this or
                           //oscilloscope.getData().clear()
                          oscilloscope.setData(FXCollections.observableArrayList());
                          oscilloscope.getData().addAll(ch1, ch2);
                          needsUpdating = true;
                      }  //end run()
                  }      //end Platform.runLater()
              }          //end if(needsUpdating)
        }                //end while(!done)
    }.start();           //end new Thread
}                        //end startDisplay()

【问题讨论】:

标签: java linux javafx raspberry-pi linechart


【解决方案1】:

我发现从图表中删除网格线非常有用。

例如

chart.setHorizontalGridLinesVisible(false);
chart.setVerticalGridLinesVisible(false);

没有尝试减少网格线的数量。

【讨论】:

  • 很多!!这个技巧可以非常快速地渲染图形! (特别是如果你包裹在滚动窗格中)为了查看参考线,我只绘制了另一条线以查看我的“警报”级别
猜你喜欢
  • 1970-01-01
  • 2013-01-14
  • 2012-08-03
  • 2018-05-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多