boolean computeAndSetRealScale(boolean redraw) {
    // compute average dpi of X and Y
    ConfigurationChooser chooser = mEditor.getConfigurationChooser();
    Configuration config = chooser.getConfiguration();
    Device device = config.getDevice();
    Screen screen = device.getDefaultHardware().getScreen();
    double dpi = (screen.getXdpi() + screen.getYdpi()) / 2.;

    // get the monitor dpi
    float monitor = AdtPrefs.getPrefs().getMonitorDensity();
    if (monitor == 0.f) {
      ResolutionChooserDialog dialog = new ResolutionChooserDialog(chooser.getShell());
      if (dialog.open() == Window.OK) {
        monitor = dialog.getDensity();
        AdtPrefs.getPrefs().setMonitorDensity(monitor);
      } else {
        return false;
      }
    }

    mEditor.getCanvasControl().setScale(monitor / dpi, redraw);
    return true;
  }
  /**
   * Sets whether the action bar should show the "lint warnings" button
   *
   * @param hasLintWarnings whether there are lint errors to be shown
   */
  private void updateErrorIndicator(final int markerCount) {
    Display display = getDisplay();
    if (display.getThread() != Thread.currentThread()) {
      display.asyncExec(
          new Runnable() {
            @Override
            public void run() {
              if (!isDisposed()) {
                updateErrorIndicator(markerCount);
              }
            }
          });
      return;
    }

    GridData layoutData = (GridData) mLintToolBar.getLayoutData();
    Integer existing = (Integer) mLintToolBar.getData();
    Integer current = Integer.valueOf(markerCount);
    if (!current.equals(existing)) {
      mLintToolBar.setData(current);
      boolean layout = false;
      boolean hasLintWarnings = markerCount > 0 && AdtPrefs.getPrefs().isLintOnSave();
      if (layoutData.exclude == hasLintWarnings) {
        layoutData.exclude = !hasLintWarnings;
        mLintToolBar.setVisible(hasLintWarnings);
        layout = true;
      }
      if (markerCount > 0) {
        String iconName = "";
        switch (markerCount) {
          case 1:
            iconName = "lint1";
            break; //$NON-NLS-1$
          case 2:
            iconName = "lint2";
            break; //$NON-NLS-1$
          case 3:
            iconName = "lint3";
            break; //$NON-NLS-1$
          case 4:
            iconName = "lint4";
            break; //$NON-NLS-1$
          case 5:
            iconName = "lint5";
            break; //$NON-NLS-1$
          case 6:
            iconName = "lint6";
            break; //$NON-NLS-1$
          case 7:
            iconName = "lint7";
            break; //$NON-NLS-1$
          case 8:
            iconName = "lint8";
            break; //$NON-NLS-1$
          case 9:
            iconName = "lint9";
            break; //$NON-NLS-1$
          default:
            iconName = "lint9p";
            break; //$NON-NLS-1$
        }
        mLintButton.setImage(IconFactory.getInstance().getIcon(iconName));
      }
      if (layout) {
        layout();
      }
      redraw();
    }
  }