Beispiel #1
0
  /** Selects the appropriate alphabet for the analysed text and sets the combo box selection. */
  private void selectAppropriateAlphabet() {
    AbstractAlphabet[] alphas = AlphabetsManager.getInstance().getAlphabets();
    String prevAlpha = myOverlayAlphabet;

    double bestrating = -99999;
    int bestindex = 0;
    double actualrating = 0;
    for (int i = 0; i < alphas.length; i++) {
      actualrating = rateAlphabetTextDifference(String.valueOf(alphas[i].getCharacterSet()), text);
      if (actualrating > bestrating) {
        bestrating = actualrating;
        bestindex = i;
      }
    }

    String bestAlphaString = String.valueOf(alphas[bestindex].getCharacterSet());
    if (bestAlphaString != null && !bestAlphaString.equals(prevAlpha)) {
      if (combo2.isVisible() && combo2.isEnabled()) {
        tipLauncher.showNewTooltip(
            combo2.toDisplay(
                new Point((int) Math.round((combo2.getSize().x) * 0.612), combo2.getSize().y)),
            9000,
            "",
            Messages.FullAnalysisUI_5); // $NON-NLS-1$
      }
    }

    combo2.select(bestindex);
    combo2WidgetSelected(null);
  }