001 package com.croftsoft.core.animation.collector;
002
003 import java.awt.Rectangle;
004 import javax.swing.JComponent;
005 import javax.swing.RepaintManager;
006
007 import com.croftsoft.core.animation.RepaintCollector;
008 import com.croftsoft.core.lang.NullArgumentException;
009
010 /*********************************************************************
011 * Routes repaint requests back to the standard Swing RepaintManager.
012 *
013 * @version
014 * 2002-12-07
015 * @since
016 * 2002-03-13
017 * @author
018 * <a href="https://www.croftsoft.com/">David Wallace Croft</a>
019 *********************************************************************/
020
021 public class SwingRepaintCollector
022 implements RepaintCollector
023 //////////////////////////////////////////////////////////////////////
024 //////////////////////////////////////////////////////////////////////
025 {
026
027 private static final Rectangle [ ] EMPTY_ARRAY = new Rectangle [ 0 ];
028
029 //
030
031 private final JComponent component;
032
033 //////////////////////////////////////////////////////////////////////
034 // constructor method
035 //////////////////////////////////////////////////////////////////////
036
037 public SwingRepaintCollector ( JComponent jComponent )
038 //////////////////////////////////////////////////////////////////////
039 {
040 NullArgumentException.check ( this.component = jComponent );
041 }
042
043 //////////////////////////////////////////////////////////////////////
044 // accessor methods
045 //////////////////////////////////////////////////////////////////////
046
047 public Rectangle [ ] getRepaintRegions ( ) { return EMPTY_ARRAY; }
048
049 public int getCount ( ) { return 0; }
050
051 //////////////////////////////////////////////////////////////////////
052 // mutator methods
053 //////////////////////////////////////////////////////////////////////
054
055 public void repaint ( )
056 //////////////////////////////////////////////////////////////////////
057 {
058 RepaintManager.currentManager ( component ).markCompletelyDirty (
059 component );
060 }
061
062 public void repaint (
063 final int x,
064 final int y,
065 final int width,
066 final int height )
067 //////////////////////////////////////////////////////////////////////
068 {
069 RepaintManager.currentManager ( component ).addDirtyRegion (
070 component, x, y, width, height );
071 }
072
073 public void reset ( )
074 //////////////////////////////////////////////////////////////////////
075 {
076 }
077
078 //////////////////////////////////////////////////////////////////////
079 //////////////////////////////////////////////////////////////////////
080 }