Exemple #1
0
  public String getLegend(String[] cityMap, int[] POIs) {
    char[] ans = new char[POIs.length];

    Hashtable hash = new Hashtable();

    for (int i = 0; i < cityMap.length; i++) {
      for (int j = 0; j < cityMap[i].length(); j++) {
        char cur = cityMap[i].charAt(j);
        int k = 1;
        if (!hash.containsKey(cur)) {
          hash.put(cur, k);
        } else {
          int prev = (int) hash.get(cur);
          hash.remove(cur);
          hash.put(cur, prev + 1);
        }
      }
    }

    Enumeration vals = hash.keys();
    while (vals.hasMoreElements()) {
      char c = (char) vals.nextElement();

      for (int i = 0; i < POIs.length; i++) {
        if (hash.get(c) == POIs[i]) {
          ans[i] = c;
        }
      }
    }

    String str = new String(ans);

    return str;
  }
  /** replaces the font (PS name) if necessary and returns the new name */
  private static String replacePSFont(String font) {
    String result;

    result = font;

    // do we have to replace it? -> same style, size
    if (m_PSFontReplacement.containsKey(font)) {
      result = m_PSFontReplacement.get(font).toString();
      if (DEBUG)
        System.out.println(
            Messages.getInstance().getString("PostscriptGraphics_ReplacePSFont_Text_First")
                + font
                + Messages.getInstance().getString("PostscriptGraphics_ReplacePSFont_Text_Second")
                + result
                + Messages.getInstance().getString("PostscriptGraphics_ReplacePSFont_Text_Third"));
    }

    return result;
  }