/**
   * This determines the amount of the progress bar that should be filled based on the percent done
   * gathered from the model. This is a common operation so it was abstracted out. It assumes that
   * your progress bar is linear. That is, if you are making a circular progress indicator, you will
   * want to override this method.
   */
  protected int getAmountFull(Insets b, int width, int height) {
    int amountFull = 0;
    BoundedRangeModel model = progressBar.getModel();

    if ((model.getMaximum() - model.getMinimum()) != 0) {
      if (progressBar.getOrientation() == JProgressBar.HORIZONTAL) {
        amountFull = (int) Math.round(width * progressBar.getPercentComplete());
      } else {
        amountFull = (int) Math.round(height * progressBar.getPercentComplete());
      }
    }
    return amountFull;
  }