4 package net.sf.openrocket.gui.customexpression;
6 import java.util.ArrayList;
7 import java.util.Arrays;
8 import java.util.Collections;
10 import javax.swing.table.AbstractTableModel;
12 import net.sf.openrocket.document.Simulation;
13 import net.sf.openrocket.l10n.Translator;
14 import net.sf.openrocket.simulation.CustomExpression;
15 import net.sf.openrocket.simulation.FlightDataType;
16 import net.sf.openrocket.startup.Application;
19 * @author Richard Graham
22 public class VariableTableModel extends AbstractTableModel {
24 private static final Translator trans = Application.getTranslator();
26 private ArrayList<FlightDataType> types = new ArrayList<FlightDataType>();
27 private static final String[] columnNames = {trans.get("customExpression.Name"), trans.get("customExpression.Symbol"), trans.get("customExpression.Units")};
30 * Table model will be constructed with all the built in variables and any custom variables defined
32 public VariableTableModel(Simulation sim){
34 Collections.addAll(types, FlightDataType.ALL_TYPES);
36 for (CustomExpression expression : sim.getCustomExpressions()){
37 types.add(expression.getType());
43 public int getColumnCount() {
48 public int getRowCount() {
53 public Object getValueAt(int row, int col) {
55 return types.get(row).getName();
57 return types.get(row).getSymbol();
59 return types.get(row).getUnitGroup().getDefaultUnit().toString();
65 public String getColumnName(int col) {
66 return columnNames[col];
69 public String getSymbolAt(int row) {
70 if (row < 0 || row > types.size()){
74 return types.get(row).getSymbol();