1   /*
2    * Copyright 2008 motej
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License. 
15   */
16  package motej.demos.balanceboard;
17  
18  import java.awt.BorderLayout;
19  
20  import javax.swing.JPanel;
21  import javax.swing.JTable;
22  
23  import motejx.extensions.balanceboard.BalanceBoardCalibrationData;
24  import motejx.extensions.balanceboard.BalanceBoardCalibrationData.Sensor;
25  import motejx.extensions.balanceboard.BalanceBoardCalibrationData.Weight;
26  
27  /**
28   * 
29   * <p>
30   * @author <a href="mailto:vfritzsch@users.sourceforge.net">Volker Fritzsch</a>
31   */
32  public class BalanceBoardCalibrationDataPanel {
33  
34  	private JPanel panel;
35  	
36  	private JTable table;
37  	
38  	public BalanceBoardCalibrationDataPanel(BalanceBoardCalibrationData cal) {
39  		String[][] data = new String[][] {
40  				{"", "KG 0", "KG 17", "KG 34"},
41  				{"Sensor A", "" + cal.getCalibration(Sensor.A, Weight.KG_0), "" + cal.getCalibration(Sensor.A, Weight.KG_17), "" + cal.getCalibration(Sensor.A, Weight.KG_34) },
42  				{"Sensor B", "" + cal.getCalibration(Sensor.B, Weight.KG_0), "" + cal.getCalibration(Sensor.B, Weight.KG_17), "" + cal.getCalibration(Sensor.B, Weight.KG_34) },
43  				{"Sensor C", "" + cal.getCalibration(Sensor.C, Weight.KG_0), "" + cal.getCalibration(Sensor.C, Weight.KG_17), "" + cal.getCalibration(Sensor.C, Weight.KG_34) },
44  				{"Sensor D", "" + cal.getCalibration(Sensor.D, Weight.KG_0), "" + cal.getCalibration(Sensor.D, Weight.KG_17), "" + cal.getCalibration(Sensor.D, Weight.KG_34) },
45  		};
46  		table = new JTable(data, new String[] {"","","",""});
47  		
48  		panel = new JPanel();
49  		panel.setLayout(new BorderLayout());
50  		panel.add(table, BorderLayout.CENTER);
51  	}
52  	
53  	public JPanel getPanel() {
54  		return panel;
55  	}
56  	
57  }