protected void scaleTo(Projection thisProj){
  if (DEBUG) {
    logger.fine("starting scaling evaluation.");
  }
  if (bitmap == null) {
    if (DEBUG) {
      logger.fine("source image is null");
    }
    return;
  }
  Rectangle winRect=new Rectangle(thisProj.getWidth(),thisProj.getHeight());
  Rectangle projRect=new Rectangle();
  projRect.setLocation(point1);
  projRect.setSize(point2.x - point1.x,point2.y - point1.y);
  Rectangle sourceRect=new Rectangle();
  sourceRect.width=bitmap.getWidth(this);
  sourceRect.height=bitmap.getHeight(this);
  clipRect=null;
  Rectangle iRect=projRect;
  if (corners == null || corners.size() <= 2) {
    iRect=winRect.intersection(projRect);
  }
  if (!iRect.isEmpty()) {
    Rectangle nClipRect=new Rectangle();
    nClipRect.setBounds(sourceRect);
    if ((iRect.width >= 1) && (iRect.height >= 1)) {
      if (!winRect.contains(projRect)) {
        double xScaleFactor=(double)sourceRect.width / (double)projRect.width;
        double yScaleFactor=(double)sourceRect.height / (double)projRect.height;
        int xOffset=iRect.x - projRect.x;
        int yOffset=iRect.y - projRect.y;
        nClipRect.x=(int)Math.floor(xOffset * xScaleFactor);
        nClipRect.y=(int)Math.floor(yOffset * yScaleFactor);
        nClipRect.width=(int)Math.ceil(iRect.width * xScaleFactor);
        nClipRect.height=(int)Math.ceil(iRect.height * yScaleFactor);
        if (nClipRect.width + nClipRect.x > sourceRect.width) {
          nClipRect.width=sourceRect.width - nClipRect.x;
        }
        if (nClipRect.height + nClipRect.y > sourceRect.height) {
          nClipRect.height=sourceRect.height - nClipRect.y;
        }
      }
      if (nClipRect.width <= 0) {
        nClipRect.width=1;
      }
      if (nClipRect.height <= 0) {
        nClipRect.height=1;
      }
      double widthAdj=(double)iRect.width / (double)nClipRect.width;
      double heightAdj=(double)iRect.height / (double)nClipRect.height;
      AffineTransform xform=new AffineTransform();
      xform.setToScale(widthAdj,heightAdj);
      clipRect=nClipRect;
      this.scalingXFormOp=new AffineTransformOp(xform,getScaleTransformType());
      point1.setLocation(iRect.x,iRect.y);
      point2.setLocation(iRect.x + iRect.width,iRect.y + iRect.height);
    }
  }
}

protected void scaleTo ( Projection thisProj ) { if ( DEBUG ) { logger . fine ( "starting scaling evaluation." ) ; } if ( bitmap == null ) { if ( DEBUG ) { logger . fine ( "source image is null" ) ; } return ; } Rectangle winRect = new Rectangle ( thisProj . getWidth ( ) , thisProj . getHeight ( ) ) ; Rectangle projRect = new Rectangle ( ) ; projRect . setLocation ( point1 ) ; projRect . setSize ( point2 . x - point1 . x , point2 . y - point1 . y ) ; Rectangle sourceRect = new Rectangle ( ) ; sourceRect . width = bitmap . getWidth ( this ) ; sourceRect . height = bitmap . getHeight ( this ) ; clipRect = null ; Rectangle iRect = projRect ; if ( corners == null || corners . size ( ) <= 2 ) { iRect = winRect . intersection ( projRect ) ; } if ( ! iRect . isEmpty ( ) ) { Rectangle nClipRect = new Rectangle ( ) ; nClipRect . setBounds ( sourceRect ) ; if ( ( iRect . width >= 1 ) && ( iRect . height >= 1 ) ) { if ( ! winRect . contains ( projRect ) ) { double xScaleFactor = ( double ) sourceRect . width / ( double ) projRect . width ; double yScaleFactor = ( double ) sourceRect . height / ( double ) projRect . height ; int xOffset = iRect . x - projRect . x ; int yOffset = iRect . y - projRect . y ; nClipRect . x = ( int ) Math . floor ( xOffset * xScaleFactor ) ; nClipRect . y = ( int ) Math . floor ( yOffset * yScaleFactor ) ; nClipRect . width = ( int ) Math . ceil ( iRect . width * xScaleFactor ) ; nClipRect . height = ( int ) Math . ceil ( iRect . height * yScaleFactor ) ; if ( nClipRect . width + nClipRect . x > sourceRect . width ) { nClipRect . width = sourceRect . width - nClipRect . x ; } if ( nClipRect . height + nClipRect . y > sourceRect . height ) { nClipRect . height = sourceRect . height - nClipRect . y ; } } if ( nClipRect . width <= 0 ) { nClipRect . width = 1 ; } if ( nClipRect . height <= 0 ) { nClipRect . height = 1 ; } double widthAdj = ( double ) iRect . width / ( double ) nClipRect . width ; double heightAdj = ( double ) iRect . height / ( double ) nClipRect . height ; AffineTransform xform = new AffineTransform ( ) ; xform . setToScale ( widthAdj , heightAdj ) ; clipRect = nClipRect ; this . scalingXFormOp = new AffineTransformOp ( xform , getScaleTransformType ( ) ) ; point1 . setLocation ( iRect . x , iRect . y ) ; point2 . setLocation ( iRect . x + iRect . width , iRect . y + iRect . height ) ; } } }
take the current projection and the sourceimage , and make the image that gets displayed fit the projection . if the source image isn ' t over the map , then this omgraphic is set to be invisible . if part of the image is on the map , only that part is used . the omraster bitmap variable is set with an image that is created from the source image , and the point1 variable is set to the point where the image should be placed . for instance , if the source image upper left corner is off the map to the northwest , then the omraster bitmap is set to a image , clipped from the source , that is entirely on the map . the omraster point1 is set to 0 , 0 , since that is where the clipped image should be placed .
