View Javadoc

1   /*
2    * Created on Apr 3, 2005 by davidson
3    */
4   package ca.spaz.cron.summary;
5   
6   import java.util.*;
7   
8   import javax.swing.JTabbedPane;
9   
10  import org.apache.log4j.Logger;
11  
12  /***
13   * A comprehensive summary of a set of consumed foods
14   * 
15   * @todo: multi day mode 
16   * @todo: Color coded to show how targets are doing 
17   * @todo: Graphs (% targets, P:F:C ratio pie chart)
18   * 
19   * @author davidson
20   * @author Chris Rose
21   */
22  public class NutritionSummaryPanel extends JTabbedPane implements Observer {
23      /***
24       * Logger for this class
25       */
26      private static final Logger logger = Logger.getLogger(NutritionSummaryPanel.class);
27  
28      private TargetSummaryChart targetPanel;
29      
30      private MacroNutrientSummaryPanel generalPanel;
31  
32      private MineralSummaryPanel mineralPanel;
33  
34      private VitaminSummaryPanel vitaminPanel;
35  
36      private AminoAcidSummaryPanel aminoAcidPanel;
37      
38      private LipidSummaryPanel lipidsPanel;
39  
40      public NutritionSummaryPanel() {
41          add("Targets", getTargetSummaryPanel());
42          add("General", getGeneralPanel());
43          add("Vitamins", getVitaminsPanel());
44          add("Minerals", getMineralsPanel());
45          add("Amino Acids", getAminoAcidsPanel());
46          add("Lipids", getLipidsPanel());
47      }
48  
49      public void update(Observable source, Object message) {
50          if (!(message instanceof List)) {
51              return;
52          }
53          List consumed = (List) message;
54          getTargetSummaryPanel().update(source, message);        
55          getGeneralPanel().update(source, message);        
56          getMineralsPanel().update(source, message);  
57          getVitaminsPanel().update(source, message);  
58          getAminoAcidsPanel().update(source, message);       
59          getLipidsPanel().update(source, message);
60      }
61  
62      private TargetSummaryChart getTargetSummaryPanel() {
63         if (null == targetPanel) {
64            targetPanel = new TargetSummaryChart();
65         }
66         return targetPanel;
67     }
68      
69      private MacroNutrientSummaryPanel getGeneralPanel() {
70          if (null == generalPanel) {
71             generalPanel = new MacroNutrientSummaryPanel();
72              //generalPanel = new NumericSummaryPanel();
73          }
74          return generalPanel;
75      }
76  
77      private VitaminSummaryPanel getVitaminsPanel() {
78          if (null == vitaminPanel) {
79              vitaminPanel = new VitaminSummaryPanel();
80          }
81          return vitaminPanel;
82      }
83  
84      private MineralSummaryPanel getMineralsPanel() {
85          if (null == mineralPanel) {
86              mineralPanel = new MineralSummaryPanel();
87          }
88          return mineralPanel;
89      }
90  
91      private AminoAcidSummaryPanel getAminoAcidsPanel() {
92          if (null == aminoAcidPanel) {
93              aminoAcidPanel = new AminoAcidSummaryPanel();
94          }
95          return aminoAcidPanel;
96      }
97  
98      private LipidSummaryPanel getLipidsPanel() {
99         if (null == lipidsPanel) {
100           lipidsPanel = new LipidSummaryPanel();
101       }
102       return lipidsPanel;
103     }
104 
105 }