Пример #1
0
  public void updatePanelSize() {

    // Set panel size.
    if (stmt != null && stmt.getWidth() > 0 && stmt.getHeight() > 0) {
      int width, height;
      switch (panel.getFitMode()) {
        case FIT_VERTICAL:
          height = getViewport().getHeight();
          width = stmt.getWidth() * height / stmt.getHeight();
          break;

        case FIT_HORIZONTAL:
          width = getViewport().getWidth();
          height = stmt.getHeight() * width / stmt.getWidth();
          break;

        case FIT_BOTH:
          width = getViewport().getWidth();
          height = getViewport().getHeight();
          break;

        case ORIGINAL:
        default:
          width = stmt.getWidth();
          height = stmt.getHeight();
          break;
      }
      panel.setPreferredSize(new Dimension(width, height));
      panel.setSize(new Dimension(width, height));
    }
  }
Пример #2
0
 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;
   }
 }
Пример #3
0
 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;
   }
 }
Пример #4
0
 private void changeFitMode() {
   switch (panel.getFitMode()) {
     case ORIGINAL:
       setFitMode(FitMode.FIT_VERTICAL);
       break;
     case FIT_VERTICAL:
       setFitMode(FitMode.FIT_HORIZONTAL);
       break;
     case FIT_HORIZONTAL:
       setFitMode(FitMode.FIT_BOTH);
       break;
     case FIT_BOTH:
     default:
       setFitMode(FitMode.ORIGINAL);
       break;
   }
 }
Пример #5
0
 public void setStmt(Stmt stmt) {
   this.stmt = stmt;
   panel.setStmt(stmt);
   setFitMode(panel.getFitMode());
   repaint();
 }