List of usage examples for javax.swing.table JTableHeader setFont
@BeanProperty(preferred = true, visualUpdate = true, description = "The font for the component.") public void setFont(Font font)
From source file:com.compomics.cell_coord.gui.controller.summary.SummaryDataController.java
/** * Initialize main view.//from w ww .j ava 2 s . c o m */ private void initSummaryDataPanel() { // create new object summaryDataPanel = new SummaryDataPanel(); // format the tables JTableHeader samplesHeader = summaryDataPanel.getSamplesTable().getTableHeader(); samplesHeader.setBackground(GuiUtils.getHeaderColor()); samplesHeader.setFont(GuiUtils.getHeaderFont()); samplesHeader.setReorderingAllowed(false); JTableHeader tracksHeader = summaryDataPanel.getTracksTable().getTableHeader(); tracksHeader.setBackground(GuiUtils.getHeaderColor()); tracksHeader.setFont(GuiUtils.getHeaderFont()); tracksHeader.setReorderingAllowed(false); JTableHeader trackSpotsHeader = summaryDataPanel.getTrackSpotsTable().getTableHeader(); trackSpotsHeader.setBackground(GuiUtils.getHeaderColor()); trackSpotsHeader.setFont(GuiUtils.getHeaderFont()); trackSpotsHeader.setReorderingAllowed(false); summaryDataPanel.getSamplesTable().setRowSelectionAllowed(true); summaryDataPanel.getSamplesTable().setColumnSelectionAllowed(false); summaryDataPanel.getSamplesTable().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); summaryDataPanel.getTracksTable().setRowSelectionAllowed(true); summaryDataPanel.getTracksTable().setColumnSelectionAllowed(false); summaryDataPanel.getTracksTable().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // if you click on a sample, the relative tracks are shown in another table summaryDataPanel.getSamplesTable().getSelectionModel() .addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { int selectedRow = summaryDataPanel.getSamplesTable().getSelectedRow(); if (selectedRow != -1) { Sample selectedSample = loadTracksController.getSamples().get(selectedRow); showTracksInTable(selectedSample); } } } }); // if you click on a track, the relative spots are shown in another table summaryDataPanel.getTracksTable().getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { Sample selectedSample = loadTracksController.getSamples() .get(summaryDataPanel.getSamplesTable().getSelectedRow()); int selectedRow = summaryDataPanel.getTracksTable().getSelectedRow(); if (selectedRow != -1) { Track selectedTrack = selectedSample.getTracks().get(selectedRow); showSpotsInTable(selectedTrack); } } } }); // add view to parent controller loadTracksController.getMainFrame().getSummaryDataParentPanel().add(summaryDataPanel, gridBagConstraints); }
From source file:com.compomics.cell_coord.gui.controller.computation.ComputationMainController.java
/** * Initialize some GUI components.// ww w . jav a2s .c o m */ private void initMainView() { // format the tables JTableHeader samplesHeader = getMainFrame().getSamplesTable().getTableHeader(); samplesHeader.setBackground(GuiUtils.getHeaderColor()); samplesHeader.setFont(GuiUtils.getHeaderFont()); samplesHeader.setReorderingAllowed(false); JTableHeader tracksHeader = getMainFrame().getTracksTable().getTableHeader(); tracksHeader.setBackground(GuiUtils.getHeaderColor()); tracksHeader.setFont(GuiUtils.getHeaderFont()); tracksHeader.setReorderingAllowed(false); getMainFrame().getSamplesTable().setRowSelectionAllowed(true); getMainFrame().getSamplesTable().setColumnSelectionAllowed(false); getMainFrame().getSamplesTable().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); getMainFrame().getTracksTable().setRowSelectionAllowed(true); getMainFrame().getTracksTable().setColumnSelectionAllowed(false); getMainFrame().getTracksTable().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // if you click on a sample, the relative tracks are shown in another table getMainFrame().getSamplesTable().getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { int selectedRow = getMainFrame().getSamplesTable().getSelectedRow(); if (selectedRow != -1) { Sample selectedSample = getSamples().get(selectedRow); showTracksInTable(selectedSample); computationDataController.computeSample(selectedSample); // call child controller to show sample data in table computationDataController.showSampleData(selectedSample); // call child controller to plot whatever we need to plot } } } }); // if you click on a track, the relative spots are shown in another table getMainFrame().getTracksTable().getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { Sample selectedSample = getSamples().get(getMainFrame().getSamplesTable().getSelectedRow()); int selectedRow = getMainFrame().getTracksTable().getSelectedRow(); if (selectedRow != -1) { Track selectedTrack = selectedSample.getTracks().get(selectedRow); // call child controller to show track data in table computationDataController.showStepData(selectedTrack); computationDataController.showTrackData(selectedTrack); // call child controller to plot whatever we need to plot computationDataController.plotStepData(selectedTrack); computationDataController.plotTrackData(selectedTrack); } } } }); }
From source file:com.sec.ose.osi.ui.frm.main.manage.AddProjectTableModel.java
public void setColumnView(JTable table) { table.setShowVerticalLines(false);/*from ww w. ja va 2s . c o m*/ table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table.setColumnSelectionAllowed(false); table.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS); table.setRowHeight(30); JTableHeader header = table.getTableHeader(); header.setPreferredSize(new java.awt.Dimension(table.getTableHeader().getWidth(), 30)); header.setFont(new Font("Arial", Font.BOLD, 12)); header.setReorderingAllowed(false); TableColumnModel cm = table.getColumnModel(); TableColumn col = null; searchHeader = new CheckBoxHeader(new CheckboxHeaderItemListener(table, COL_ISSELECT), ""); col = cm.getColumn(COL_ISSELECT); col.setHeaderRenderer(searchHeader); }
From source file:com.sec.ose.osi.ui.frm.main.manage.ManagedProjectTableModel.java
public void setColumnType(JTable table) { table.setShowVerticalLines(false);//from w w w. ja v a 2s. com table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table.setColumnSelectionAllowed(false); table.setRowSelectionAllowed(false); table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); table.setRowHeight(30); JTableHeader header = table.getTableHeader(); header.setPreferredSize(new java.awt.Dimension(table.getTableHeader().getWidth(), 30)); header.setFont(new Font("Arial", Font.BOLD, 12)); header.setReorderingAllowed(false); TableColumnModel cm = table.getColumnModel(); TableColumn col = null; analyzeHeader = new CheckBoxHeader(new CheckboxHeaderItemListener(table, COL_ANALYZE_TARGET), "Analyze Target"); col = cm.getColumn(COL_ANALYZE_TARGET); col.setHeaderRenderer(analyzeHeader); JCheckBox chkbox = new JCheckBox(); chkbox.setBackground(Color.white); chkbox.setHorizontalAlignment(JLabel.CENTER); col.setCellRenderer(new DefaultTableCellRenderer() { private static final long serialVersionUID = 1L; public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { ManagedProjectTableModel model = (ManagedProjectTableModel) table.getModel(); String sPrjName = (String) table.getValueAt(row, ManagedProjectTableModel.COL_PROJECT_NAME); OSIProjectInfo item = model.getProjectInfo(sPrjName); JCheckBox chkbox = new JCheckBox(); chkbox.setSelected(((Boolean) value).booleanValue()); if (item != null) { chkbox.setEnabled(item.isLocationValid()); } chkbox.setHorizontalAlignment(JLabel.CENTER); chkbox.setBackground(Color.white); return (Component) chkbox; } }); col.setCellEditor(new DefaultCellEditor(chkbox)); col = cm.getColumn(COL_ANALYZE_STATUS); col.setCellRenderer(new StatusIconCellRenderer()); col = cm.getColumn(COL_SOURCE_LOCATION); col.setCellRenderer(new FileBrowseCellRenderer()); col.setCellEditor(new FileBrowseCellEditor()); }
From source file:com.compomics.cell_coord.gui.controller.computation.ComputationDataController.java
/** * Initialize main view./* w ww . j a v a2 s . c o m*/ */ private void initComputationDataPanel() { // make a new object computationDataPanel = new ComputationDataPanel(); // format the tables JTableHeader header = computationDataPanel.getStepDataTable().getTableHeader(); header.setBackground(GuiUtils.getHeaderColor()); header.setFont(GuiUtils.getHeaderFont()); header.setReorderingAllowed(false); header = computationDataPanel.getSampleDataTable().getTableHeader(); header.setBackground(GuiUtils.getHeaderColor()); header.setFont(GuiUtils.getHeaderFont()); header.setReorderingAllowed(false); header = computationDataPanel.getSampleDataTable().getTableHeader(); header.setBackground(GuiUtils.getHeaderColor()); header.setFont(GuiUtils.getHeaderFont()); header.setReorderingAllowed(false); header = computationDataPanel.getTrackDataTable().getTableHeader(); header.setBackground(GuiUtils.getHeaderColor()); header.setFont(GuiUtils.getHeaderFont()); header.setReorderingAllowed(false); computationDataPanel.getStepDataTable().setRowSelectionAllowed(true); computationDataPanel.getStepDataTable().setColumnSelectionAllowed(false); computationDataPanel.getStepDataTable().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); computationDataPanel.getStepDataTable().setRowSelectionAllowed(true); computationDataPanel.getStepDataTable().setColumnSelectionAllowed(false); computationDataPanel.getStepDataTable().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // add component to main container computationMainController.getMainFrame().getComputationDataParentPanel().add(computationDataPanel, gridBagConstraints); }
From source file:com.compomics.cell_coord.gui.controller.load.LoadTracksController.java
/** * Initialize the view components./* w w w. j a va2s . c om*/ */ private void initView() { // create new view loadTracksPanel = new LoadTracksPanel(); // disable the IMPORT FILES button loadTracksPanel.getImportFilesButton().setEnabled(false); // initialize the flag to keep track of importing isImported = false; // populate the combobox with available file formats // note: these are annoatated as spring beans Set<String> parsers = TrackFileParserFactory.getInstance().getParserBeanNames(); for (String parser : parsers) { loadTracksPanel.getFileFormatComboBox().addItem(parser); } // format the table JTableHeader tracksTableHeader = loadTracksPanel.getTracksTable().getTableHeader(); tracksTableHeader.setBackground(GuiUtils.getHeaderColor()); tracksTableHeader.setFont(GuiUtils.getHeaderFont()); tracksTableHeader.setReorderingAllowed(false); /** * Action Listeners. */ // load directory loadTracksPanel.getLoadDirectoryButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (directory == null) { chooseDirectoryAndLoadData(); } else { // otherwise we ask the user if they want to reload the directory Object[] options = { "Load a different directory", "Cancel" }; int showOptionDialog = JOptionPane.showOptionDialog(null, "It seems a directory was already loaded.\nWhat do you want to do?", "", JOptionPane.CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[1]); switch (showOptionDialog) { case 0: // load a different directory: // reset the model of the directory tree DefaultTreeModel model = (DefaultTreeModel) loadTracksPanel.getDirectoryTree().getModel(); DefaultMutableTreeNode rootNote = (DefaultMutableTreeNode) model.getRoot(); rootNote.removeAllChildren(); model.reload(); chooseDirectoryAndLoadData(); loadTracksPanel.getChosenDirectoryTextArea().setText(directory.getAbsolutePath()); break; // cancel: do nothing } } } }); // import the selected files in the tree loadTracksPanel.getImportFilesButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // check if an import already took place if (!isImported) { // get the selected file(s) from the JTree TreePath[] selectionPaths = loadTracksPanel.getDirectoryTree().getSelectionPaths(); if (selectionPaths != null && selectionPaths.length != 0) { // at least a file was selected -- proceed with the import importFiles(); isImported = true; cellCoordController.showMessage(selectionPaths.length + " file(s) successfully imported!", "success loading", JOptionPane.INFORMATION_MESSAGE); // do basic computations preprocess(); // go to child controllers and show samples in the tables summaryDataController.showSamplesInTable(); computationMainController.showSamplesInTable(); // proceed with next step in the plugin cellCoordController.getCellCoordFrame().getNextButton().setEnabled(true); } else { // inform the user that no file was selected! cellCoordController.showMessage("You have to select at least one file!", "no files selected", JOptionPane.WARNING_MESSAGE); } } else { // an import already took place: ask for user input Object[] options = { "Load other file(s)", "Cancel" }; int showOptionDialog = JOptionPane.showOptionDialog(loadTracksPanel, "It seems some files were already loaded.\nWhat do you want to do?", "", JOptionPane.CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[1]); switch (showOptionDialog) { case 0: // load other files // clear the sample list samples.clear(); // clear the track spot list trackSpotsBindingList.clear(); // clear the selection in the JTree loadTracksPanel.getDirectoryTree().clearSelection(); isImported = false; // inform the user they need to select other files JOptionPane.showMessageDialog(loadTracksPanel, "Please select other files", "", JOptionPane.INFORMATION_MESSAGE); break; // cancel: do nothing } } } }); // add view to parent component cellCoordController.getCellCoordFrame().getLoadTracksParentPanel().add(loadTracksPanel, gridBagConstraints); }
From source file:nl.phanos.liteliveresultsclient.gui.ResultsWindows.java
public void ChangeFont(int fontSize) { JTableHeader header = jTable1.getTableHeader(); header.setSize(header.getWidth(), fontSize + 5); jTable1.setFont(new java.awt.Font("Lucida Grande", 0, fontSize)); // NOI18N SerieLabel.setFont(new java.awt.Font("Lucida Grande", 0, fontSize)); // NOI18N SerieLabel.setSize(SerieLabel.getWidth(), fontSize + 5); jPanel1.setSize(SerieLabel.getWidth(), fontSize + 5); jTable1.setRowHeight(fontSize + 5);// w w w. j av a 2s. co m logoLabel.setBounds(this.getWidth() - icon.getIconWidth(), this.getHeight() - icon.getIconHeight(), icon.getIconWidth(), icon.getIconHeight()); header.setFont(new java.awt.Font("Lucida Grande", 0, fontSize)); // NOI18N clockLabel.setFont(new java.awt.Font("Lucida Grande", 0, fontSize)); // NOI18N clockLabel.setBounds(0, this.getHeight() - (fontSize + 15), fontSize * 30, (fontSize + 5)); repaint(); }
From source file:org.ut.biolab.medsavant.client.view.genetics.variantinfo.VariantFrequencyAggregatePane.java
public void setVariantRecords(Set<VariantRecord> records) { innerPanel.removeAll();//from ww w . j av a 2s .c om //This function executes quickly, no need for waitPanel. //innerPanel.add(new WaitPanel("Loading DNA Ids...")); tableModel.setValues(records); aggregateTable = new AggregateTable(tableModel) { @Override //Necessary to enable buttons within the table. public boolean isCellEditable(int rowIndex, int colIndex) { return colIndex == buttonIndex; } //"Disables" selection within the aggregateTable. @Override public TableCellRenderer getCellRenderer(final int rowIndex, final int columnIndex) { final TableCellRenderer renderer = super.getCellRenderer(rowIndex, columnIndex); return new TableCellRenderer() { @Override public Component getTableCellRendererComponent(JTable jtable, final Object o, boolean bln, boolean bln1, int i, int i1) { return renderer.getTableCellRendererComponent(jtable, o, false, false, i, i1); } }; } //This overridden method, together with the custom mouse listener on the //AggregateTable header, disallows moving the first column, and columns //>= dnaIDIndex @Override protected AggregateTable.DraggingHandler createDraggingColumnPropertyChangeListener() { return new AggregateTable.DraggingHandler() { @Override public void columnMoved(TableColumnModelEvent e) { if (fromColumnIndex == -1) { fromColumnIndex = e.getFromIndex(); } toColumnIndex = e.getToIndex(); } }; } }; header = new AggregateTableHeader(aggregateTable); header.addMouseListener(new MouseAdapter() { //Disable moving the first column, or columns with index //>=dnaIDIndex @Override public void mouseReleased(MouseEvent e) { if (toColumnIndex != -1 && ((toColumnIndex == 0 || fromColumnIndex == 0) || (toColumnIndex >= dnaIDIndex || fromColumnIndex >= dnaIDIndex))) { aggregateTable.moveColumn(toColumnIndex, fromColumnIndex); String msg = "This column cannot be moved."; DialogUtils.displayMessage(msg); } else { for (int columnHeaderIndex = 0; columnHeaderIndex < header.getColumnModel().getColumnCount() - 2; columnHeaderIndex++) { String columnTitle = (String) header.getColumnModel().getColumn(columnHeaderIndex) .getHeaderValue(); aggregateColumns[columnHeaderIndex] = columnTitle; } reaggregate(); } //aggregateTable.aggregate(this.aggregateColumns); fromColumnIndex = -1; toColumnIndex = -1; //expandAllButLast(); } }); header.setAutoFilterEnabled(false); header.setReorderingAllowed(true); header.setFont(TABLE_FONT_LARGE); aggregateTable.setTableHeader(header); aggregateTable.setAutoResizeMode(AggregateTable.AUTO_RESIZE_ALL_COLUMNS); aggregateTable.setFont(TABLE_FONT_LARGE); //Setup a custom "summary". This is what calculates frequencies when cells are //collapsed PivotField f = aggregateTable.getAggregateTableModel().getField(BasicVariantColumns.DNA_ID.getAlias()); f.setSummaryType(PivotConstants.SUMMARY_RESERVED_MAX + 1); aggregateTable.getAggregateTableModel().setSummaryCalculator(new SummaryCalculator() { private Set<String> collapsedDNAIDs = new HashSet<String>(); private Values lastRowValues; private int valueCount = 0; private final int SUMMARY_FREQ = PivotConstants.SUMMARY_RESERVED_MAX + 1; @Override public void addValue(PivotValueProvider dataModel, PivotField field, Values rowValues, Values columnValues, Object object) { //this gets called multiple times for all the cells that disappear when //something is collapsed. // row[0] is the value of the corresponding first column: e.g. a Cohort or Family. // columnValues can be ignored (blank) // Object is the value of the item in the cell that disappeared. (i.e. those cells which are being summarized) // field.getName() is the column name corresponding to Object // Useful Debugging code: //if(field.getName().equals(BasicVariantColumns.DNA_ID.getAlias())){ /* System.out.println("=========="); System.out.println("Field : " + field.getName()); System.out.println("Row values: "); for (int i = 0; i < rowValues.getCount(); ++i) { System.out.println("\trow[" + i + "] = " + rowValues.getValueAt(i).getValue()); } System.out.println("Column values: "); for (int i = 0; i < columnValues.getCount(); ++i) { System.out.println("\tcol[" + i + "] = " + columnValues.getValueAt(i).getValue()); } System.out.println("Object: "); System.out.println("\t" + object); System.out.println("=========="); */ // } if (field.getName().equals(BasicVariantColumns.DNA_ID.getAlias())) { collapsedDNAIDs.add((String) object); lastRowValues = rowValues; } else { lastRowValues = null; } valueCount++; } //Should never be called @Override public void addValue(Object o) { LOG.error("Unexpected method invocation in OtherIndividualsSubInspector (1)"); } //Should never be called @Override public void addValue(IPivotDataModel ipdm, PivotField pf, int i, int i1, Object o) { LOG.error("Unexpected method invocation in OtherIndividualsSubInspector (2)"); } //Should never be called @Override public void addValue(PivotValueProvider pvp, PivotField pf, Object o) { LOG.error("Unexpected method invocation in OtherIndividualsSubInspector (3)"); } @Override public void clear() { collapsedDNAIDs.clear(); valueCount = 0; lastRowValues = null; } @Override public Object getSummaryResult(int type) { //if null, then we're not in the DNAId column. Return null //to show a blank in this cell if (lastRowValues == null) { return null; } int numIndividuals = getNumberOfIndividualsInGroup(lastRowValues.getValueAt(0)); return new Frequency(collapsedDNAIDs.size(), numIndividuals); } private int getNumberOfIndividualsInGroup(Value v) { if (aggregateColumns[0].equals("Cohort")) { //LOG.debug("Getting number of individuals in group " + v.getValue()); Set<String> dnaIds = cohortDNAIDMap.get((Cohort) v.getValue()); //for (String id : dnaIds) { //LOG.debug("\tGot id " + id); //} return cohortDNAIDMap.get((Cohort) v.getValue()).size(); } else if (aggregateColumns[0].equals(BasicPatientColumns.FAMILY_ID.getAlias())) { return familyIDdnaIDMap.get((String) v.getValue()).size(); } else { LOG.error("Invalid first column"); return -1; } } @Override public long getCount() { return valueCount; } @Override public int getNumberOfSummaries() { return 1; } @Override public String getSummaryName(Locale locale, int i) { return "Frequency"; } @Override public int[] getAllowedSummaries(Class<?> type) { return new int[] { SUMMARY_FREQ }; } @Override public int[] getAllowedSummaries(Class<?> type, ConverterContext cc) { return new int[] { SUMMARY_FREQ }; } }); //Sets up the context menu for clicking column headers. This will probably not be used //frequently. Limit the available operations to collapsing, expanding, and grouping. TableHeaderPopupMenuInstaller installer = new TableHeaderPopupMenuInstaller(aggregateTable); installer.addTableHeaderPopupMenuCustomizer(new AggregateTablePopupMenuCustomizer() { @Override public void customizePopupMenu(JTableHeader header, JPopupMenu popup, int clickingColumn) { super.customizePopupMenu(header, popup, clickingColumn); for (int i = 0; i < popup.getComponentCount(); i++) { String menuItemName = popup.getComponent(i).getName(); if (!(CONTEXT_MENU_COLLAPSE.equals(menuItemName) || CONTEXT_MENU_COLLAPSE_ALL.equals(menuItemName) || CONTEXT_MENU_EXPAND.equals(menuItemName) || CONTEXT_MENU_EXPAND_ALL.equals(menuItemName) || CONTEXT_MENU_GROUP.equals(menuItemName) || CONTEXT_MENU_UNGROUP.equals(menuItemName))) { popup.remove(popup.getComponent(i)); } } } }); aggregateTable.getAggregateTableModel().setSummaryMode(true); aggregateTable.aggregate(aggregateColumns); aggregateTable.setShowContextMenu(false); expandAllButLast(); setupButtonColumn(); JScrollPane jsp = new JScrollPane(aggregateTable); jsp.setPreferredSize(PREFERRED_SIZE); JPanel bp = new JPanel(); bp.setLayout(new BoxLayout(bp, BoxLayout.X_AXIS)); JButton closeButton = new JButton(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.CLOSE)); closeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { unsplitScreen(); } }); bp.add(Box.createHorizontalGlue()); bp.add(title); bp.add(Box.createHorizontalGlue()); bp.add(closeButton); innerPanel.add(bp); innerPanel.add(jsp); reaggregate(); innerPanel.revalidate(); innerPanel.repaint(); }