/** * Set TextField and TA values from model * @param selectedRow Selected row */ private void setValues(int selectedRow) { nameTF.setText((String)tableModel.getValueAt(selectedRow, 0)); valueTA.setInitialText((String)tableModel.getValueAt(selectedRow, 1)); valueTA.setCaretPosition(0); textChanged = false; }
public String[] getFiles() { String[] _files = new String[tableModel.getRowCount()]; for (int idx=0; idx < _files.length; idx++) { _files[idx] = (String)tableModel.getValueAt(idx,0); } return _files; }
/** * replace the argument value of the selection with a variable * the variable name is derived from the parameter name */ private void transformNameIntoVariable() { int[] rowsSelected = getTable().getSelectedRows(); for (int selectedRow : rowsSelected) { String name = (String) tableModel.getValueAt(selectedRow, 0); if (StringUtils.isNotBlank(name)) { name = name.trim(); name = name.replaceAll("\\$", "_"); name = name.replaceAll("\\{", "_"); name = name.replaceAll("\\}", "_"); tableModel.setValueAt("${" + name + "}", selectedRow, 1); } } }
public String[] getAxisLabels() { if (model.getRowCount() > 1) { int count = model.getRowCount() -1; String[] labels = new String[count]; for (int idx=0; idx < count; idx++) { labels[idx] = (String)model.getValueAt(idx,0); } return labels; } // API expects null, not empty array return null; }
public Object getValueAt(int column) { return getModel().getValueAt(getIndex(), column); } }
/** * We use this method to get the data, since we are using * ObjectTableModel, so the calling getDataVector doesn't * work as expected. * * @param model {@link ObjectTableModel} * @param formats Array of {@link Format} array can contain null formatters in this case value is added as is * @return the data from the model */ public static List<List<Object>> getAllTableData(ObjectTableModel model, Format[] formats) { List<List<Object>> data = new ArrayList<List<Object>>(); if (model.getRowCount() > 0) { for (int rw = 0; rw < model.getRowCount(); rw++) { int cols = model.getColumnCount(); List<Object> column = new ArrayList<Object>(); data.add(column); for (int idx = 0; idx < cols; idx++) { Object val = model.getValueAt(rw, idx); if (formats[idx] != null) { column.add(formats[idx].format(val)); } else { column.add(val); } } } } return data; }
/** * We use this method to get the data, since we are using * ObjectTableModel, so the calling getDataVector doesn't * work as expected. * * @param model {@link ObjectTableModel} * @param formats Array of {@link Format} array can contain null formatters in this case value is added as is * @return the data from the model */ public static List<List<Object>> getAllTableData(ObjectTableModel model, Format[] formats) { List<List<Object>> data = new ArrayList<>(); if (model.getRowCount() > 0) { for (int rw = 0; rw < model.getRowCount(); rw++) { int cols = model.getColumnCount(); List<Object> column = new ArrayList<>(); data.add(column); for (int idx = 0; idx < cols; idx++) { Object val = model.getValueAt(rw, idx); if (formats[idx] != null) { column.add(formats[idx].format(val)); } else { column.add(val); } } } } return data; }
/** * We use this method to get the data, since we are using * ObjectTableModel, so the calling getDataVector doesn't * work as expected. * @param model {@link ObjectTableModel} * @param formats Array of {@link Format} array can contain null formatters in this case value is added as is * @return the data from the model */ public static List<List<Object>> getAllTableData(ObjectTableModel model, Format[] formats) { List<List<Object>> data = new ArrayList<>(); if (model.getRowCount() > 0) { for (int rw=0; rw < model.getRowCount(); rw++) { int cols = model.getColumnCount(); List<Object> column = new ArrayList<>(); data.add(column); for (int idx=0; idx < cols; idx++) { Object val = model.getValueAt(rw,idx); if(formats[idx] != null) { column.add(formats[idx].format(val)); } else { column.add(val); } } } } return data; }
public double[][] getData() { if (model.getRowCount() > 1) { int count = model.getRowCount() -1; int size = nbColToGraph; double[][] data = new double[size][count]; int s = 0; int cpt = 0; for (BarGraph bar : eltList) { if (bar.getChkBox().isSelected()) { int col = model.findColumn(columnsList.getItemAt(cpt)); for (int idx=0; idx < count; idx++) { data[s][idx] = ((Number)model.getValueAt(idx,col)).doubleValue(); } s++; } cpt++; } return data; } // API expects null, not empty array return null; }