Class RateLimiterAdaptsToRenderTime

  • All Implemented Interfaces:
    RateLimiter

    public class RateLimiterAdaptsToRenderTime
    extends RateLimiterByMilisecond
    implements RateLimiter
    This rate limiter keeps an history of past rendering time to auto configure the rate limit and ensure we stick to actual rendering time before doing an action. This rate limiter is useful to ensure a controller such as mouse or thread won't ask more rendering than possible. The time limit is computed as follow
    • Compute the maximum rendering time in the list of the 10 last rendering time
    • Adds a 20ms margin
    This allows adapting the rate limit if the rendering capabilities changes, which may happen according to a changing canvas size, changing screen, changing HiDPI settings, changing content of chart.
    • Field Detail

    • Constructor Detail

      • RateLimiterAdaptsToRenderTime

        public RateLimiterAdaptsToRenderTime​(ICanvas canvas)
      • RateLimiterAdaptsToRenderTime

        public RateLimiterAdaptsToRenderTime()
    • Method Detail

      • adaptRateLimitToRenderTimeHistory

        protected void adaptRateLimitToRenderTimeHistory()
      • getLastRenderingTimeFromCanvas

        protected double getLastRenderingTimeFromCanvas()
      • max

        protected double max​(Queue<Double> renderingTimeHistory)
      • getCanvas

        public ICanvas getCanvas()
      • setCanvas

        public void setCanvas​(ICanvas canvas)