Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: jpicedt/ui/util/DebugRepaintManager.java


1   /*  jPicEdt version 1.3.2, a picture editor for LaTeX.
2       Copyright (C) 1999-2002  Sylvain Reynal
3   
4       This program is free software; you can redistribute it and/or modify
5       it under the terms of the GNU General Public License as published by
6       the Free Software Foundation; either version 2 of the License, or
7       (at your option) any later version.
8   
9       This program is distributed in the hope that it will be useful,
10      but WITHOUT ANY WARRANTY; without even the implied warranty of
11      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12      GNU General Public License for more details.
13  
14      You should have received a copy of the GNU General Public License
15      along with this program; if not, write to the Free Software
16      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17  
18      Sylvain Reynal
19      Département de Physique
20      Ecole Nationale Supérieure de l'Electronique et de ses Applications (ENSEA)
21      6, avenue du Ponceau
22      95014 CERGY CEDEX
23      FRANCE
24  
25      Tel : 00 +33 130 736 245
26      Fax : 00 +33 130 736 667
27      e-mail : reynal@ensea.fr
28      jPicEdt web page : http://www.jpicedt.org
29  */
30  
31  package jpicedt.ui.util;
32  
33  import java.awt.*;
34  import java.awt.event.*;
35  import javax.swing.*;
36  
37  /**
38   * A RepaintManager that may used for debugging purpose<p>
39   * Print out information about adding and/or painting dirty regions<br>
40   * How to use it :<br> 
41   * - Set DEBUG_PAINTING to TRUE in JPicEdt.java<br>
42   * - launch jpicedt with "-redir=standard"<br>
43   */
44  public class DebugRepaintManager extends RepaintManager {
45  
46    // set to true to display information concerning jpicedt.* components only.
47    private static final boolean ONLY_JPICEDT_COMPONENTS = true;
48  
49    /**
50      * creates a new DebugRepaintManager with double-buffering turned off
51     */
52    public DebugRepaintManager(){
53      super();
54      setDoubleBufferingEnabled(false);
55    }
56    
57    /**
58     * Add a component in the list of components that should be refreshed. 
59     * If c already has a dirty region, the rectangle (x,y,w,h) will be unioned with the region that should be redrawn.
60     */
61    public synchronized void addDirtyRegion(JComponent c, int x, int y, int w, int h) {
62  
63      if (ONLY_JPICEDT_COMPONENTS){
64  
65        if (c.getClass().getName().startsWith("jpicedt.graphic.PECanvas"))
66          jpicedt.Log.debug(this,"adding DirtyRegion: "+c.getClass().getName()+", "+x+","+y+" "+w+"x"+h);
67      }
68      else {
69        jpicedt.Log.debug(this,"adding DirtyRegion: "+c.getClass().getName()+", "+x+","+y+" "+w+"x"+h);
70      }
71      super.addDirtyRegion(c,x,y,w,h);
72  
73    }
74  
75    /**
76     * Paint all of the components that have been marked dirty.
77     */
78    public void paintDirtyRegions() {
79  
80      // Unfortunately most of the RepaintManager state is package
81      // private and not accessible from the subclass at the moment,
82      // so we can't print more info about what's being painted.
83      jpicedt.Log.debug(this,"painting DirtyRegions");
84      super.paintDirtyRegions();
85    }
86  }
87  
88