| %line | %branch | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| ca.spaz.cron.summary.NumericSummaryPanel |
|
|
| 1 | /* |
|
| 2 | ******************************************************************************* |
|
| 3 | * Copyright (c) 2005 Chris Rose and AIMedia |
|
| 4 | * All rights reserved. AminoAcidSummaryPanel and the accompanying materials |
|
| 5 | * are made available under the terms of the Common Public License v1.0 |
|
| 6 | * which accompanies this distribution, and is available at |
|
| 7 | * http://www.eclipse.org/legal/cpl-v10.html |
|
| 8 | * |
|
| 9 | * Contributors: |
|
| 10 | * Chris Rose |
|
| 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 | 0 | super(); |
| 39 | 0 | df = new DecimalFormat("######0.0"); |
| 40 | 0 | for (Iterator iter = nutrientInfos.iterator(); iter.hasNext();) { |
| 41 | 0 | NutrientInfo inf = (NutrientInfo) iter.next(); |
| 42 | 0 | addValueField(inf.getTag(), inf.getName(), inf.getUnits()); |
| 43 | 0 | } |
| 44 | ||
| 45 | 0 | addContentPane("Numeric", new SimpleSummaryContent(this)); |
| 46 | 0 | generateContentPane(); |
| 47 | 0 | } |
| 48 | ||
| 49 | /* (non-Javadoc) |
|
| 50 | * @see ca.spaz.cron.SummaryPanel#doDoubleString(java.lang.String, java.lang.Double) |
|
| 51 | */ |
|
| 52 | protected String doDoubleString(String valueName, Double value) { |
|
| 53 | 0 | return df.format(value) + " " + getUnit(valueName); |
| 54 | } |
|
| 55 | } |
| This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |