private void updateView(){
  xOffset=0;
  yOffset=0;
  if (mapImage == null) {
    return;
  }
  final int imageWidth=mapImage.getWidth(null);
  final int imageHeight=mapImage.getHeight(null);
  final int xpos=(int)((playerX * scale) + 0.5) - width / 2;
  final int ypos=(int)((playerY * scale) + 0.5) - width / 2;
  if (imageWidth > width) {
    if ((xpos + width) > imageWidth) {
      xOffset=imageWidth - width;
    }
 else     if (xpos > 0) {
      xOffset=xpos;
    }
  }
  if (imageHeight > height) {
    if ((ypos + height) > imageHeight) {
      yOffset=imageHeight - height;
    }
 else     if (ypos > 0) {
      yOffset=ypos;
    }
  }
}

private void updateView ( ) { xOffset = 0 ; yOffset = 0 ; if ( mapImage == null ) { return ; } final int imageWidth = mapImage . getWidth ( null ) ; final int imageHeight = mapImage . getHeight ( null ) ; final int xpos = ( int ) ( ( playerX * scale ) + 0.5 ) - width / 2 ; final int ypos = ( int ) ( ( playerY * scale ) + 0.5 ) - width / 2 ; if ( imageWidth > width ) { if ( ( xpos + width ) > imageWidth ) { xOffset = imageWidth - width ; } else if ( xpos > 0 ) { xOffset = xpos ; } } if ( imageHeight > height ) { if ( ( ypos + height ) > imageHeight ) { yOffset = imageHeight - height ; } else if ( ypos > 0 ) { yOffset = ypos ; } } }
update the view pan . this should be done when the map size or player position changes . this must be called from the event dispatch thread .
