/** * Creates the Factor definition subform * * @return - JPanel containing the Factor definition subform. */ private Container createTransposedView() { Box subformContainer = Box.createVerticalBox(); transposedSpreadsheetSubform = new TransposedSubForm( "spreadsheet data", FieldTypes.ROW, transposedSpreadsheetModel.getFields(), transposedSpreadsheetModel.getNumberOfRecords(), width, height, transposedSpreadsheetModel.getData(), transposedSpreadsheetModel.getSpreadsheet().getDataEntryEnv()); transposedSpreadsheetSubform.createGUI(); transposedSpreadsheetSubform.addPropertyChangeListener( "rowAdded", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent propertyChangeEvent) { updateInformation(); } }); subformContainer.add(Box.createVerticalStrut(15)); subformContainer.add(transposedSpreadsheetSubform); subformContainer.add(Box.createVerticalStrut(15)); return subformContainer; }
private void updateInformation() { information.setText( "<html><font color=\"#8DC63F\"><b>" + transposedSpreadsheetSubform.getScrollTable().getColumnCount() + "</b></font> records annotated with <font color=\"#8DC63F\"><b>" + transposedSpreadsheetModel.getFields().size() + "</b></font> metadata fields</html>"); }
private void goToColumn(JTextField field) { int index; try { index = Integer.valueOf(field.getText()); if (index > 0 && index <= transposedSpreadsheetSubform.getScrollTable().getColumnCount()) { scrollToColumnLocation(index - 1); } else { field.setText("invalid"); } } catch (NumberFormatException nfe) { field.setText("invalid"); } }
public void scrollToColumnLocation(int colIndex) { JTable scrollTable = transposedSpreadsheetSubform.getScrollTable(); scrollTable.setColumnSelectionInterval(colIndex, colIndex); JViewport scrollPane = transposedSpreadsheetSubform.getFrozenTable().getViewport(); Rectangle rect = scrollTable.getCellRect(1, colIndex, true); Point p = scrollPane.getViewPosition(); rect.setLocation(rect.x - p.x, rect.y - p.y); scrollPane.scrollRectToVisible(rect); Map<Integer, Color> columnToColor = new HashMap<Integer, Color>(); columnToColor.put(colIndex, new Color(28, 117, 188, 70)); transposedSpreadsheetSubform.changeTableRenderer( transposedSpreadsheetSubform.getScrollTable(), new SubFormCellRenderer( UIHelper.VER_11_PLAIN, UIHelper.DARK_GREEN_COLOR, null, columnToColor)); transposedSpreadsheetSubform.validate(); transposedSpreadsheetSubform.repaint(); }