< prev index next >

src/java.desktop/share/classes/javax/swing/RepaintManager.java

Print this page




 319         // poses a problem we'll need a more sophisticated detection algorithm,
 320         // or API.
 321         this(BUFFER_STRATEGY_SPECIFIED_OFF);
 322     }
 323 
 324     private RepaintManager(short bufferStrategyType) {
 325         // If native doublebuffering is being used, do NOT use
 326         // Swing doublebuffering.
 327         doubleBufferingEnabled = !nativeDoubleBuffering;
 328         synchronized(this) {
 329             dirtyComponents = new IdentityHashMap<Component,Rectangle>();
 330             tmpDirtyComponents = new IdentityHashMap<Component,Rectangle>();
 331             this.bufferStrategyType = bufferStrategyType;
 332             hwDirtyComponents = new IdentityHashMap<Container,Rectangle>();
 333         }
 334         processingRunnable = new ProcessingRunnable();
 335     }
 336 
 337     private void displayChanged() {
 338         clearImages();




 339     }
 340 
 341     /**
 342      * Mark the component as in need of layout and queue a runnable
 343      * for the event dispatching thread that will validate the components
 344      * first isValidateRoot() ancestor.
 345      *
 346      * @param invalidComponent a component
 347      * @see JComponent#isValidateRoot
 348      * @see #removeInvalidComponent
 349      */
 350     public synchronized void addInvalidComponent(JComponent invalidComponent)
 351     {
 352         RepaintManager delegate = getDelegate(invalidComponent);
 353         if (delegate != null) {
 354             delegate.addInvalidComponent(invalidComponent);
 355             return;
 356         }
 357         Component validateRoot =
 358             SwingUtilities.getValidateRoot(invalidComponent, true);


1190      * Returns the maximum double buffer size.
1191      *
1192      * @return a Dimension object representing the maximum size
1193      */
1194     public Dimension getDoubleBufferMaximumSize() {
1195         if (doubleBufferMaxSize == null) {
1196             try {
1197                 Rectangle virtualBounds = new Rectangle();
1198                 GraphicsEnvironment ge = GraphicsEnvironment.
1199                                                  getLocalGraphicsEnvironment();
1200                 for (GraphicsDevice gd : ge.getScreenDevices()) {
1201                     GraphicsConfiguration gc = gd.getDefaultConfiguration();
1202                     virtualBounds = virtualBounds.union(gc.getBounds());
1203                 }
1204                 doubleBufferMaxSize = new Dimension(virtualBounds.width,
1205                                                     virtualBounds.height);
1206             } catch (HeadlessException e) {
1207                 doubleBufferMaxSize = new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
1208             }
1209         }



1210         return doubleBufferMaxSize;
1211     }
1212 
1213     /**
1214      * Enables or disables double buffering in this RepaintManager.
1215      * CAUTION: The default value for this property is set for optimal
1216      * paint performance on the given platform and it is not recommended
1217      * that programs modify this property directly.
1218      *
1219      * @param aFlag  true to activate double buffering
1220      * @see #isDoubleBufferingEnabled
1221      */
1222     public void setDoubleBufferingEnabled(boolean aFlag) {
1223         doubleBufferingEnabled = aFlag;
1224         PaintManager paintManager = getPaintManager();
1225         if (!aFlag && paintManager.getClass() != PaintManager.class) {
1226             setPaintManager(new PaintManager());
1227         }
1228     }
1229 




 319         // poses a problem we'll need a more sophisticated detection algorithm,
 320         // or API.
 321         this(BUFFER_STRATEGY_SPECIFIED_OFF);
 322     }
 323 
 324     private RepaintManager(short bufferStrategyType) {
 325         // If native doublebuffering is being used, do NOT use
 326         // Swing doublebuffering.
 327         doubleBufferingEnabled = !nativeDoubleBuffering;
 328         synchronized(this) {
 329             dirtyComponents = new IdentityHashMap<Component,Rectangle>();
 330             tmpDirtyComponents = new IdentityHashMap<Component,Rectangle>();
 331             this.bufferStrategyType = bufferStrategyType;
 332             hwDirtyComponents = new IdentityHashMap<Container,Rectangle>();
 333         }
 334         processingRunnable = new ProcessingRunnable();
 335     }
 336 
 337     private void displayChanged() {
 338         clearImages();
 339 
 340         // Reset buffer maximum size to get valid size from updated graphics
 341         // environment in getDoubleBufferMaximumSize()
 342         setDoubleBufferMaximumSize(null);
 343     }
 344 
 345     /**
 346      * Mark the component as in need of layout and queue a runnable
 347      * for the event dispatching thread that will validate the components
 348      * first isValidateRoot() ancestor.
 349      *
 350      * @param invalidComponent a component
 351      * @see JComponent#isValidateRoot
 352      * @see #removeInvalidComponent
 353      */
 354     public synchronized void addInvalidComponent(JComponent invalidComponent)
 355     {
 356         RepaintManager delegate = getDelegate(invalidComponent);
 357         if (delegate != null) {
 358             delegate.addInvalidComponent(invalidComponent);
 359             return;
 360         }
 361         Component validateRoot =
 362             SwingUtilities.getValidateRoot(invalidComponent, true);


1194      * Returns the maximum double buffer size.
1195      *
1196      * @return a Dimension object representing the maximum size
1197      */
1198     public Dimension getDoubleBufferMaximumSize() {
1199         if (doubleBufferMaxSize == null) {
1200             try {
1201                 Rectangle virtualBounds = new Rectangle();
1202                 GraphicsEnvironment ge = GraphicsEnvironment.
1203                                                  getLocalGraphicsEnvironment();
1204                 for (GraphicsDevice gd : ge.getScreenDevices()) {
1205                     GraphicsConfiguration gc = gd.getDefaultConfiguration();
1206                     virtualBounds = virtualBounds.union(gc.getBounds());
1207                 }
1208                 doubleBufferMaxSize = new Dimension(virtualBounds.width,
1209                                                     virtualBounds.height);
1210             } catch (HeadlessException e) {
1211                 doubleBufferMaxSize = new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
1212             }
1213         }
1214         if (doubleBufferMaxSize != null) {
1215             System.err.println("Buffer size " +  doubleBufferMaxSize.width + ", " + doubleBufferMaxSize.height);
1216         }
1217         return doubleBufferMaxSize;
1218     }
1219 
1220     /**
1221      * Enables or disables double buffering in this RepaintManager.
1222      * CAUTION: The default value for this property is set for optimal
1223      * paint performance on the given platform and it is not recommended
1224      * that programs modify this property directly.
1225      *
1226      * @param aFlag  true to activate double buffering
1227      * @see #isDoubleBufferingEnabled
1228      */
1229     public void setDoubleBufferingEnabled(boolean aFlag) {
1230         doubleBufferingEnabled = aFlag;
1231         PaintManager paintManager = getPaintManager();
1232         if (!aFlag && paintManager.getClass() != PaintManager.class) {
1233             setPaintManager(new PaintManager());
1234         }
1235     }
1236 


< prev index next >