private void toggleUnderlayImage(){
  if (enableBgImage.isSelected()) {
    String imgFile=null;
    int[] offsets;
    double scale, rotate;
    BufferedImage image;
    try {
      Settings settings=new Settings(UNDERLAY_NS);
      imgFile=settings.getSetting("fileName");
      offsets=settings.getCsvInts("offset",2);
      scale=settings.getDouble("scale");
      rotate=settings.getDouble("rotate");
      image=ImageIO.read(new File(imgFile));
    }
 catch (    IOException ex) {
      warn("Couldn't set underlay image " + imgFile + ". "+ ex.getMessage());
      enableBgImage.setSelected(false);
      return;
    }
catch (    SettingsError er) {
      warn("Problem with the underlay image settings: " + er.getMessage());
      return;
    }
    field.setUnderlayImage(image,offsets[0],offsets[1],scale,rotate);
  }
 else {
    field.setUnderlayImage(null,0,0,0,0);
  }
}

private void toggleUnderlayImage ( ) { if ( enableBgImage . isSelected ( ) ) { String imgFile = null ; int [ ] offsets ; double scale , rotate ; BufferedImage image ; try { Settings settings = new Settings ( UNDERLAY_NS ) ; imgFile = settings . getSetting ( "fileName" ) ; offsets = settings . getCsvInts ( "offset" , 2 ) ; scale = settings . getDouble ( "scale" ) ; rotate = settings . getDouble ( "rotate" ) ; image = ImageIO . read ( new File ( imgFile ) ) ; } catch ( IOException ex ) { warn ( "Couldn't set underlay image " + imgFile + ". " + ex . getMessage ( ) ) ; enableBgImage . setSelected ( false ) ; return ; } catch ( SettingsError er ) { warn ( "Problem with the underlay image settings: " + er . getMessage ( ) ) ; return ; } field . setUnderlayImage ( image , offsets [ 0 ] , offsets [ 1 ] , scale , rotate ) ; } else { field . setUnderlayImage ( null , 0 , 0 , 0 , 0 ) ; } }
toggles the showing of underlay image . image is read from the file only when it is enabled to save some memory .
