Class LazyCanvasResizer

  • All Implemented Interfaces:
    java.awt.event.ComponentListener, java.util.EventListener

    public abstract class LazyCanvasResizer
    extends java.awt.event.ComponentAdapter
    Class to lazily process canvas resize events by applying a threshold.
    Since:
    0.2
    Author:
    Erich Schubert
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) double activeRatio
      Last ratio of the Canvas applied
      (package private) java.awt.Component component
      Component the ratio applies to.
      static double DEFAULT_THRESHOLD
      Default threshold for resizing.
      (package private) double threshold
      Active threshold
    • Constructor Summary

      Constructors 
      Constructor Description
      LazyCanvasResizer​(java.awt.Component component)
      Simplified constructor using the default threshold DEFAULT_THRESHOLD
      LazyCanvasResizer​(java.awt.Component component, double threshold)
      Full constructor.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void componentResized​(java.awt.event.ComponentEvent e)
      React to a component resize event.
      abstract void executeResize​(double newratio)
      Callback function that needs to be overridden with actual implementations.
      double getActiveRatio()
      Get the components last applied ratio.
      double getCurrentRatio()
      Get the components current ratio.
      • Methods inherited from class java.awt.event.ComponentAdapter

        componentHidden, componentMoved, componentShown
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DEFAULT_THRESHOLD

        public static final double DEFAULT_THRESHOLD
        Default threshold for resizing.
        See Also:
        Constant Field Values
      • threshold

        double threshold
        Active threshold
      • activeRatio

        double activeRatio
        Last ratio of the Canvas applied
      • component

        java.awt.Component component
        Component the ratio applies to.
    • Constructor Detail

      • LazyCanvasResizer

        public LazyCanvasResizer​(java.awt.Component component,
                                 double threshold)
        Full constructor.
        Parameters:
        component - Component to track
        threshold - Threshold
      • LazyCanvasResizer

        public LazyCanvasResizer​(java.awt.Component component)
        Simplified constructor using the default threshold DEFAULT_THRESHOLD
        Parameters:
        component - Component to track.
    • Method Detail

      • componentResized

        public void componentResized​(java.awt.event.ComponentEvent e)
        React to a component resize event.
        Specified by:
        componentResized in interface java.awt.event.ComponentListener
        Overrides:
        componentResized in class java.awt.event.ComponentAdapter
      • getCurrentRatio

        public final double getCurrentRatio()
        Get the components current ratio.
        Returns:
        Current ratio.
      • executeResize

        public abstract void executeResize​(double newratio)
        Callback function that needs to be overridden with actual implementations.
        Parameters:
        newratio - New ratio to apply.
      • getActiveRatio

        public double getActiveRatio()
        Get the components last applied ratio.
        Returns:
        Last applied ratio.