コード例 #1
0
ファイル: PieChartGenerator.java プロジェクト: JayH5/mason
 // Sorts labels from the mapping.  We may get rid of this later perhaps.
 String[] revisedLabels(HashMap map) {
   // Sort labels
   String[] labels = new String[map.size()];
   labels = (String[]) (map.keySet().toArray(labels));
   Arrays.sort(labels);
   return labels;
 }
コード例 #2
0
ファイル: PieChartGenerator.java プロジェクト: JayH5/mason
 // Returns the counts from the mapping, in the same order as the labels
 double[] amounts(HashMap map, String[] revisedLabels) {
   // Extract amounts
   double[] amounts = new double[map.size()];
   for (int i = 0; i < amounts.length; i++)
     amounts[i] = ((Double) (map.get(revisedLabels[i]))).doubleValue();
   return amounts;
 }
コード例 #3
0
ファイル: PieChartGenerator.java プロジェクト: JayH5/mason
 // Takes objects and produces an object->count mapping
 HashMap convertIntoAmountsAndLabels(Object[] objs) {
   // Total the amounts
   HashMap map = new HashMap();
   for (int i = 0; i < objs.length; i++) {
     String label = "null";
     if (objs[i] != null) label = objs[i].toString();
     if (map.containsKey(label))
       map.put(label, new Double(((Double) (map.get(label))).doubleValue() + 1));
     else map.put(label, new Double(1));
   }
   return map;
 }
コード例 #4
0
 /**
  * List the fonts known to the PDF renderer. This is like PFont.list(), however not all those
  * fonts are available by default.
  */
 @SuppressWarnings("unchecked")
 public static String[] listFonts() {
   if (fontList == null) {
     HashMap<?, ?> map = getMapper().getAliases();
     //      Set entries = map.entrySet();
     //      fontList = new String[entries.size()];
     fontList = new String[map.size()];
     int count = 0;
     for (Object entry : map.entrySet()) {
       fontList[count++] = (String) ((Map.Entry) entry).getKey();
     }
     //      Iterator it = entries.iterator();
     //      int count = 0;
     //      while (it.hasNext()) {
     //        Map.Entry entry = (Map.Entry) it.next();
     //        //System.out.println(entry.getKey() + "-->" + entry.getValue());
     //        fontList[count++] = (String) entry.getKey();
     //      }
     fontList = PApplet.sort(fontList);
   }
   return fontList;
 }