public void paintDirty(){
  int size=0;
synchronized (displayLock) {
    size=paintQueueFill;
    Animation[] array=paintQueue;
    paintQueue=paintQueueTemp;
    paintQueueTemp=array;
    paintQueueFill=0;
  }
  if (size > 0) {
    Graphics wrapper=getCodenameOneGraphics();
    int dwidth=getDisplayWidth();
    int dheight=getDisplayHeight();
    int topX=dwidth;
    int topY=dheight;
    int bottomX=0;
    int bottomY=0;
    for (int iter=0; iter < size; iter++) {
      Animation ani=paintQueueTemp[iter];
      if (ani == null) {
        continue;
      }
      paintQueueTemp[iter]=null;
      wrapper.translate(-wrapper.getTranslateX(),-wrapper.getTranslateY());
      wrapper.setClip(0,0,dwidth,dheight);
      if (ani instanceof Component) {
        Component cmp=(Component)ani;
        Rectangle dirty=cmp.getDirtyRegion();
        if (dirty != null) {
          Dimension d=dirty.getSize();
          wrapper.setClip(dirty.getX(),dirty.getY(),d.getWidth(),d.getHeight());
          cmp.setDirtyRegion(null);
        }
        cmp.paintComponent(wrapper);
        getPaintableBounds(cmp,paintDirtyTmpRect);
        int cmpAbsX=paintDirtyTmpRect.getX();
        topX=Math.min(cmpAbsX,topX);
        bottomX=Math.max(cmpAbsX + paintDirtyTmpRect.getWidth(),bottomX);
        int cmpAbsY=paintDirtyTmpRect.getY();
        topY=Math.min(cmpAbsY,topY);
        bottomY=Math.max(cmpAbsY + paintDirtyTmpRect.getHeight(),bottomY);
      }
 else {
        bottomX=dwidth;
        bottomY=dheight;
        topX=0;
        topY=0;
        ani.paint(wrapper);
      }
    }
    paintOverlay(wrapper);
    flushGraphics(topX,topY,bottomX - topX,bottomY - topY);
  }
}

public void paintDirty ( ) { int size = 0 ; synchronized ( displayLock ) { size = paintQueueFill ; Animation [ ] array = paintQueue ; paintQueue = paintQueueTemp ; paintQueueTemp = array ; paintQueueFill = 0 ; } if ( size > 0 ) { Graphics wrapper = getCodenameOneGraphics ( ) ; int dwidth = getDisplayWidth ( ) ; int dheight = getDisplayHeight ( ) ; int topX = dwidth ; int topY = dheight ; int bottomX = 0 ; int bottomY = 0 ; for ( int iter = 0 ; iter < size ; iter ++ ) { Animation ani = paintQueueTemp [ iter ] ; if ( ani == null ) { continue ; } paintQueueTemp [ iter ] = null ; wrapper . translate ( - wrapper . getTranslateX ( ) , - wrapper . getTranslateY ( ) ) ; wrapper . setClip ( 0 , 0 , dwidth , dheight ) ; if ( ani instanceof Component ) { Component cmp = ( Component ) ani ; Rectangle dirty = cmp . getDirtyRegion ( ) ; if ( dirty != null ) { Dimension d = dirty . getSize ( ) ; wrapper . setClip ( dirty . getX ( ) , dirty . getY ( ) , d . getWidth ( ) , d . getHeight ( ) ) ; cmp . setDirtyRegion ( null ) ; } cmp . paintComponent ( wrapper ) ; getPaintableBounds ( cmp , paintDirtyTmpRect ) ; int cmpAbsX = paintDirtyTmpRect . getX ( ) ; topX = Math . min ( cmpAbsX , topX ) ; bottomX = Math . max ( cmpAbsX + paintDirtyTmpRect . getWidth ( ) , bottomX ) ; int cmpAbsY = paintDirtyTmpRect . getY ( ) ; topY = Math . min ( cmpAbsY , topY ) ; bottomY = Math . max ( cmpAbsY + paintDirtyTmpRect . getHeight ( ) , bottomY ) ; } else { bottomX = dwidth ; bottomY = dheight ; topX = 0 ; topY = 0 ; ani . paint ( wrapper ) ; } } paintOverlay ( wrapper ) ; flushGraphics ( topX , topY , bottomX - topX , bottomY - topY ) ; } }
invoked by the edt to paint the dirty regions
