I need help with this simple animation on my Android phone. I am new to animation and graphics.
I collect accelerometer data as a window of a moving time series. When new accelerometer data is read, its data is displayed on the right, pushing the previous data to the left, as shown below:

My program works pretty smoothly, but I would like some help optimizing the animation. Here are my main concerns:
My current implementation reads all the accelerometer data in one stream and saves the data in a FIFO queue of a fixed size to fix the window width of the time series. Then I use Timer.scheduleAtFixedRate () to plot the entire contents of the queue so that the entire graph is redrawn every 50 milliseconds. Can i improve this? Do I really need to re-draw a graph as often as this? In another similar program that I saw, each column of pixels is copied one pixel to the left, ripples down the graph; the newest data column is drawn in the rightmost column of the pixel. This is better?
I redraw the legend (in the upper left corner) in the drawing stream, which launches the drawing function every 50 milliseconds. Is there a way to โsaveโ this legend instead of constantly re-drawing it?
Any other help would be greatly appreciated. I have heard about optimizations such as double buffering, but I donโt know if this would help me.
source share