public void constrain(int x,int y,int w,int h,Region region){
  if ((x | y) != 0) {
    translate(x,y);
  }
  if (transformState > TRANSFORM_TRANSLATESCALE) {
    clipRect(0,0,w,h);
    return;
  }
  final double scaleX=transform.getScaleX();
  final double scaleY=transform.getScaleY();
  x=constrainX=(int)transform.getTranslateX();
  y=constrainY=(int)transform.getTranslateY();
  w=Region.dimAdd(x,Region.clipScale(w,scaleX));
  h=Region.dimAdd(y,Region.clipScale(h,scaleY));
  Region c=constrainClip;
  if (c == null) {
    c=Region.getInstanceXYXY(x,y,w,h);
  }
 else {
    c=c.getIntersectionXYXY(x,y,w,h);
  }
  if (region != null) {
    region=region.getScaledRegion(scaleX,scaleY);
    region=region.getTranslatedRegion(x,y);
    c=c.getIntersection(region);
  }
  if (c == constrainClip) {
    return;
  }
  constrainClip=c;
  if (!devClip.isInsideQuickCheck(c)) {
    devClip=devClip.getIntersection(c);
    validateCompClip();
  }
}

public void constrain ( int x , int y , int w , int h , Region region ) { if ( ( x | y ) != 0 ) { translate ( x , y ) ; } if ( transformState > TRANSFORM_TRANSLATESCALE ) { clipRect ( 0 , 0 , w , h ) ; return ; } final double scaleX = transform . getScaleX ( ) ; final double scaleY = transform . getScaleY ( ) ; x = constrainX = ( int ) transform . getTranslateX ( ) ; y = constrainY = ( int ) transform . getTranslateY ( ) ; w = Region . dimAdd ( x , Region . clipScale ( w , scaleX ) ) ; h = Region . dimAdd ( y , Region . clipScale ( h , scaleY ) ) ; Region c = constrainClip ; if ( c == null ) { c = Region . getInstanceXYXY ( x , y , w , h ) ; } else { c = c . getIntersectionXYXY ( x , y , w , h ) ; } if ( region != null ) { region = region . getScaledRegion ( scaleX , scaleY ) ; region = region . getTranslatedRegion ( x , y ) ; c = c . getIntersection ( region ) ; } if ( c == constrainClip ) { return ; } constrainClip = c ; if ( ! devClip . isInsideQuickCheck ( c ) ) { devClip = devClip . getIntersection ( c ) ; validateCompClip ( ) ; } }
constrain rendering for lightweight objects .
