• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Graphing with real time update

Matthew Smith
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm devloping an app which has to graph data from a serial unit in real time. The app controls the data source, it interrogates the device periodically and then should update the graph with each new data point. In order to keep the rate of data acquisition regular (down to 125ms per sample) obviously the painting needs to be as efficient as possible. Redrawing the whole graph (the grid and the data tracks) each iteration has proved too costly so I'm looking for a way to just draw the tracks.
My current idea is to have a JPanel for the grid (GraphPanel, say) and then another JPanel (TrackPanel, say)for each track. The track panels would be transparent and draw only the data track corresponding to that panel. Then on each update of the data I need only repaint the TrackPanels and not the GraphPanel. A custom layout that I have written makes each TrackPanel fit to the size of the GraphPanel (with multiple tracks overlayed).
The problem here is that as the TrackPanels are not opaque then the repaint delegates up to the GraphPanel anyway. Obviously with setOpaque(true) the GraphPanel doesn't draw at all.
The only way I have got a satisfactory result in terms of performance is by using an incremental style painting system which is very bad as it relies on getting its own graphics context and it occurs outside the event/paint thread.
Would a custom repaint manager allow me to stop the repaint on TrackPanels delegating to the GraphPanel? Would it be difficult to implement?
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic