1
2
3
4
5
6
7
8
9
10
11
12 package ca.spaz.cron.summary;
13
14 import java.text.DecimalFormat;
15 import java.util.*;
16
17 import ca.spaz.cron.database.NutrientInfo;
18
19 /***
20 * Generic summary panel. Displays numeric data for all properties
21 * set on the summary panel, properly formatted.
22 *
23 * @deprecated No longer needed for UI
24 * @author Chris Rose
25 */
26 public class NumericSummaryPanel extends SwitchableSummaryPanel {
27
28 private DecimalFormat df;
29
30 /***
31 * Construct a new NumericSummaryPanel with the supplied nutrient values.
32 * @param nutrientInfos a <code>List</code> containing <code>NutrientInfo</code>
33 * objects.
34 * @throws <code>ClassCastException</code> if there are objects other than
35 * <code>NutrientInfo</code> objects in the list.
36 */
37 public NumericSummaryPanel(List nutrientInfos) {
38 super();
39 df = new DecimalFormat("######0.0");
40 for (Iterator iter = nutrientInfos.iterator(); iter.hasNext();) {
41 NutrientInfo inf = (NutrientInfo) iter.next();
42 addValueField(inf.getTag(), inf.getName(), inf.getUnits());
43 }
44
45 addContentPane("Numeric", new SimpleSummaryContent(this));
46 generateContentPane();
47 }
48
49
50
51
52 protected String doDoubleString(String valueName, Double value) {
53 return df.format(value) + " " + getUnit(valueName);
54 }
55 }