public int imageToViewY(int y) {
   switch (panel.getFitMode()) {
     case FIT_BOTH:
     case FIT_VERTICAL:
       return y * panel.getHeight() / stmt.getHeight();
     case FIT_HORIZONTAL:
       return y * panel.getWidth() / stmt.getWidth();
     default:
       return y;
   }
 }
 public int viewToImageX(int x) {
   switch (panel.getFitMode()) {
     case FIT_BOTH:
     case FIT_HORIZONTAL:
       return x * stmt.getWidth() / panel.getWidth();
     case FIT_VERTICAL:
       return x * stmt.getHeight() / panel.getHeight();
     default:
       return x;
   }
 }