use of jam.table.TableRenderer in project beast-mcmc by beast-dev.
the class SpeciesSetPanel method initTableColumn.
protected void initTableColumn() {
final TableColumnModel tableColumnModel = taxonSetsTable.getColumnModel();
TableColumn tableColumn = tableColumnModel.getColumn(0);
tableColumn.setCellRenderer(new TableRenderer(SwingConstants.LEFT, new Insets(0, 4, 0, 4)));
tableColumn.setMinWidth(20);
tableColumn = tableColumnModel.getColumn(1);
tableColumn.setPreferredWidth(10);
}
use of jam.table.TableRenderer in project beast-mcmc by beast-dev.
the class TaxonSetPanel method initTableColumn.
protected void initTableColumn() {
tableColumnModel = taxonSetsTable.getColumnModel();
TableColumn tableColumn = tableColumnModel.getColumn(0);
tableColumn.setCellRenderer(new TableRenderer(SwingConstants.LEFT, new Insets(0, 4, 0, 4)));
tableColumn.setMinWidth(20);
tableColumn = tableColumnModel.getColumn(1);
tableColumn.setPreferredWidth(20);
tableColumn = tableColumnModel.getColumn(2);
tableColumn.setPreferredWidth(20);
tableColumn = tableColumnModel.getColumn(3);
comboBoxRenderer.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE);
tableColumn.setCellRenderer(comboBoxRenderer);
tableColumn.setPreferredWidth(30);
tableColumn = tableColumnModel.getColumn(4);
tableColumn.setCellEditor(new DateCellEditor(true));
tableColumn.setPreferredWidth(30);
}
use of jam.table.TableRenderer in project beast-mcmc by beast-dev.
the class TaxonSetPanel method initPanel.
protected void initPanel(Action addTaxonSetAction, Action removeTaxonSetAction) {
JScrollPane scrollPane1 = new JScrollPane(taxonSetsTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
JToolBar toolBar1 = new JToolBar();
toolBar1.setFloatable(false);
toolBar1.setOpaque(false);
toolBar1.setBorder(BorderFactory.createEmptyBorder());
toolBar1.setLayout(new FlowLayout(java.awt.FlowLayout.LEFT, 0, 0));
JButton button = new JButton(importTaxonSetsAction);
PanelUtils.setupComponent(button);
toolBar1.add(button);
ActionPanel actionPanel1 = new ActionPanel(false);
actionPanel1.setAddAction(addTaxonSetAction);
actionPanel1.setRemoveAction(removeTaxonSetAction);
addTaxonSetAction.setEnabled(false);
removeTaxonSetAction.setEnabled(false);
JPanel controlPanel1 = new JPanel(new FlowLayout(FlowLayout.LEFT));
controlPanel1.add(actionPanel1);
// Excluded Taxon List
excludedTaxaTableModel = new TaxaTableModel(false);
excludedTaxaTable = new JTable(excludedTaxaTableModel);
excludedTaxaTable.getColumnModel().getColumn(0).setCellRenderer(new TableRenderer(SwingConstants.LEFT, new Insets(0, 4, 0, 4)));
excludedTaxaTable.getColumnModel().getColumn(0).setMinWidth(20);
excludedTaxaTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent evt) {
excludedTaxaTableSelectionChanged();
}
});
JScrollPane scrollPane2 = new JScrollPane(excludedTaxaTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
includedTaxonSetsComboBox = new JComboBox(new String[] { TAXON.toLowerCase() + "..." });
excludedTaxonSetsComboBox = new JComboBox(new String[] { TAXON.toLowerCase() + "..." });
includedTaxaLabel.setText("");
excludedTaxaLabel.setText("");
Box panel1 = new Box(BoxLayout.X_AXIS);
panel1.add(new JLabel("Select: "));
panel1.setOpaque(false);
excludedTaxonSetsComboBox.setOpaque(false);
panel1.add(excludedTaxonSetsComboBox);
// Included Taxon List
includedTaxaTableModel = new TaxaTableModel(true);
includedTaxaTable = new JTable(includedTaxaTableModel);
includedTaxaTable.getColumnModel().getColumn(0).setCellRenderer(new TableRenderer(SwingConstants.LEFT, new Insets(0, 4, 0, 4)));
includedTaxaTable.getColumnModel().getColumn(0).setMinWidth(20);
includedTaxaTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent evt) {
includedTaxaTableSelectionChanged();
}
});
includedTaxaTable.doLayout();
JScrollPane scrollPane3 = new JScrollPane(includedTaxaTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
Box panel2 = new Box(BoxLayout.X_AXIS);
panel2.add(new JLabel("Select: "));
panel2.setOpaque(false);
includedTaxonSetsComboBox.setOpaque(false);
panel2.add(includedTaxonSetsComboBox);
Icon includeIcon = null, excludeIcon = null;
try {
includeIcon = new ImageIcon(IconUtils.getImage(BeautiApp.class, "images/include.png"));
excludeIcon = new ImageIcon(IconUtils.getImage(BeautiApp.class, "images/exclude.png"));
} catch (Exception e) {
// do nothing
}
JPanel buttonPanel = createAddRemoveButtonPanel(includeTaxonAction, includeIcon, "Include selected " + TAXA.toLowerCase() + " in the " + TAXON.toLowerCase(), excludeTaxonAction, excludeIcon, "Exclude selected " + TAXA.toLowerCase() + " from the " + TAXON.toLowerCase(), BoxLayout.Y_AXIS);
taxonSetEditingPanel = new JPanel();
taxonSetEditingPanel.setBorder(BorderFactory.createTitledBorder(""));
taxonSetEditingPanel.setOpaque(false);
taxonSetEditingPanel.setLayout(new GridBagLayout());
excludedTaxaSearchField.setColumns(12);
// excludedTaxaSearchField.putClientProperty("JTextField.variant", "search");
excludedTaxaSearchField.putClientProperty("Quaqua.TextField.style", "search");
excludedTaxaSearchField.putClientProperty("Quaqua.TextField.sizeVariant", "small");
includedTaxaSearchField.setColumns(12);
// includedTaxaSearchField.putClientProperty("JTextField.variant", "search");
includedTaxaSearchField.putClientProperty("Quaqua.TextField.style", "search");
includedTaxaSearchField.putClientProperty("Quaqua.TextField.sizeVariant", "small");
GridBagConstraints c = new GridBagConstraints();
c.gridx = 0;
c.gridy = 0;
c.weightx = 0.5;
c.weighty = 0;
c.fill = GridBagConstraints.HORIZONTAL;
c.anchor = GridBagConstraints.CENTER;
c.insets = new Insets(3, 6, 3, 0);
taxonSetEditingPanel.add(excludedTaxaSearchField, c);
c.gridx = 0;
c.gridy = 1;
c.weightx = 0.5;
c.weighty = 1;
c.fill = GridBagConstraints.BOTH;
c.anchor = GridBagConstraints.CENTER;
c.insets = new Insets(0, 6, 0, 0);
taxonSetEditingPanel.add(scrollPane2, c);
c.gridx = 0;
c.gridy = 2;
c.weightx = 0.5;
c.weighty = 0;
c.fill = GridBagConstraints.HORIZONTAL;
c.anchor = GridBagConstraints.CENTER;
c.insets = new Insets(0, 6, 3, 0);
taxonSetEditingPanel.add(excludedTaxaLabel, c);
c.gridx = 0;
c.gridy = 3;
c.weightx = 0.5;
c.weighty = 0;
c.fill = GridBagConstraints.HORIZONTAL;
c.anchor = GridBagConstraints.CENTER;
c.insets = new Insets(0, 6, 3, 0);
taxonSetEditingPanel.add(panel1, c);
c.gridx = 1;
c.gridy = 0;
c.weightx = 0;
c.weighty = 1;
c.gridheight = 4;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.CENTER;
c.insets = new Insets(12, 2, 12, 4);
taxonSetEditingPanel.add(buttonPanel, c);
c.gridx = 2;
c.gridy = 0;
c.weightx = 0.5;
c.weighty = 0;
c.gridheight = 1;
c.fill = GridBagConstraints.HORIZONTAL;
c.anchor = GridBagConstraints.CENTER;
c.insets = new Insets(3, 0, 3, 6);
taxonSetEditingPanel.add(includedTaxaSearchField, c);
c.gridx = 2;
c.gridy = 1;
c.weightx = 0.5;
c.weighty = 1;
c.fill = GridBagConstraints.BOTH;
c.anchor = GridBagConstraints.CENTER;
c.insets = new Insets(0, 0, 0, 6);
taxonSetEditingPanel.add(scrollPane3, c);
c.gridx = 2;
c.gridy = 2;
c.weightx = 0.5;
c.weighty = 0;
c.fill = GridBagConstraints.HORIZONTAL;
c.anchor = GridBagConstraints.CENTER;
c.insets = new Insets(0, 0, 3, 6);
taxonSetEditingPanel.add(includedTaxaLabel, c);
c.gridx = 2;
c.gridy = 3;
c.weightx = 0.5;
c.weighty = 0;
c.fill = GridBagConstraints.HORIZONTAL;
c.anchor = GridBagConstraints.CENTER;
c.insets = new Insets(0, 0, 3, 6);
taxonSetEditingPanel.add(panel2, c);
JPanel panel3 = new JPanel();
panel3.setOpaque(false);
panel3.setLayout(new GridBagLayout());
c = new GridBagConstraints();
c.gridx = 0;
c.gridy = 0;
c.weightx = 0.5;
c.weighty = 1;
c.fill = GridBagConstraints.BOTH;
c.anchor = GridBagConstraints.CENTER;
c.insets = new Insets(0, 0, 2, 12);
panel3.add(scrollPane1, c);
c.gridx = 0;
c.gridy = 1;
c.weightx = 0;
c.weighty = 0;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.WEST;
c.insets = new Insets(2, 0, 0, 12);
panel3.add(actionPanel1, c);
c.gridx = 1;
c.gridy = 0;
c.weightx = 0.5;
c.weighty = 1;
c.fill = GridBagConstraints.BOTH;
c.anchor = GridBagConstraints.CENTER;
c.insets = new Insets(0, 0, 0, 0);
panel3.add(taxonSetEditingPanel, c);
setOpaque(false);
setBorder(new BorderUIResource.EmptyBorderUIResource(new Insets(12, 12, 12, 12)));
setLayout(new BorderLayout(0, 0));
add(toolBar1, BorderLayout.NORTH);
add(panel3, BorderLayout.CENTER);
// taxonSetsTable.addMouseListener(new MouseAdapter() {
// public void mouseClicked(MouseEvent e) {
// if (e.getClickCount() == 2) {
// JTable target = (JTable)e.getSource();
// int row = target.getSelectedRow();
// taxonSetsTableDoubleClicked(row);
// }
// }
// });
includedTaxaSearchField.getDocument().addDocumentListener(new DocumentListener() {
public void changedUpdate(DocumentEvent e) {
selectIncludedTaxa(includedTaxaSearchField.getText());
}
public void removeUpdate(DocumentEvent e) {
selectIncludedTaxa(includedTaxaSearchField.getText());
}
public void insertUpdate(DocumentEvent e) {
selectIncludedTaxa(includedTaxaSearchField.getText());
}
});
excludedTaxaSearchField.getDocument().addDocumentListener(new DocumentListener() {
public void changedUpdate(DocumentEvent e) {
selectExcludedTaxa(excludedTaxaSearchField.getText());
}
public void removeUpdate(DocumentEvent e) {
selectExcludedTaxa(excludedTaxaSearchField.getText());
}
public void insertUpdate(DocumentEvent e) {
selectExcludedTaxa(excludedTaxaSearchField.getText());
}
});
includedTaxaTable.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2) {
includeSelectedTaxa();
}
}
});
excludedTaxaTable.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2) {
excludeSelectedTaxa();
}
}
});
includedTaxaTable.addFocusListener(new FocusAdapter() {
public void focusGained(FocusEvent focusEvent) {
excludedTaxaTable.clearSelection();
}
});
excludedTaxaTable.addFocusListener(new FocusAdapter() {
public void focusGained(FocusEvent focusEvent) {
includedTaxaTable.clearSelection();
}
});
includedTaxaTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
if (!includedSelectionChanging) {
if (includedTaxonSetsComboBox.getSelectedIndex() != 0) {
includedTaxonSetsComboBox.setSelectedIndex(0);
}
includedTaxaSearchField.setText("");
}
}
});
includedTaxonSetsComboBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
includedSelectionChanging = true;
includedTaxaTable.clearSelection();
if (includedTaxonSetsComboBox.getSelectedIndex() > 0) {
String taxaName = includedTaxonSetsComboBox.getSelectedItem().toString();
if (!taxaName.endsWith("...")) {
Taxa taxa = options.getTaxa(taxaName);
if (taxa != null) {
for (int i = 0; i < taxa.getTaxonCount(); i++) {
Taxon taxon = taxa.getTaxon(i);
int index = includedTaxa.indexOf(taxon);
includedTaxaTable.getSelectionModel().addSelectionInterval(index, index);
}
}
}
}
includedSelectionChanging = false;
}
});
excludedTaxaTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
if (!excludedSelectionChanging) {
if (excludedTaxonSetsComboBox.getSelectedIndex() != 0) {
excludedTaxonSetsComboBox.setSelectedIndex(0);
}
excludedTaxaSearchField.setText("");
}
}
});
excludedTaxonSetsComboBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
excludedSelectionChanging = true;
excludedTaxaTable.clearSelection();
if (excludedTaxonSetsComboBox.getSelectedIndex() > 0) {
String taxaName = excludedTaxonSetsComboBox.getSelectedItem().toString();
if (!taxaName.endsWith("...")) {
Taxa taxa = options.getTaxa(taxaName);
if (taxa != null) {
for (int i = 0; i < taxa.getTaxonCount(); i++) {
Taxon taxon = taxa.getTaxon(i);
int index = excludedTaxa.indexOf(taxon);
excludedTaxaTable.getSelectionModel().addSelectionInterval(index, index);
}
}
}
}
excludedSelectionChanging = false;
}
});
includedTaxaTable.doLayout();
excludedTaxaTable.doLayout();
}
use of jam.table.TableRenderer in project beast-mcmc by beast-dev.
the class MapperFrameOld method initializeComponents.
public void initializeComponents() {
setSize(new java.awt.Dimension(1200, 800));
mapperPanel = new MapperPanel(this);
mapperPanel.setBorder(new BorderUIResource.EmptyBorderUIResource(new java.awt.Insets(12, 6, 12, 12)));
traceTableModel = new TraceTableModel();
traceTable = new JTable(traceTableModel);
TableRenderer renderer = new TableRenderer(SwingConstants.LEFT, new Insets(0, 4, 0, 4));
traceTable.getColumnModel().getColumn(0).setCellRenderer(renderer);
traceTable.getColumnModel().getColumn(1).setPreferredWidth(50);
traceTable.getColumnModel().getColumn(1).setCellRenderer(renderer);
traceTable.getColumnModel().getColumn(2).setPreferredWidth(50);
traceTable.getColumnModel().getColumn(2).setCellRenderer(renderer);
traceTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
traceTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent evt) {
traceTableSelectionChanged();
}
});
scrollPane1 = new JScrollPane(traceTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
ActionPanel actionPanel1 = new ActionPanel(false);
actionPanel1.setAddAction(getImportAction());
actionPanel1.setRemoveAction(getRemoveTraceAction());
getRemoveTraceAction().setEnabled(false);
JPanel controlPanel1 = new JPanel(new FlowLayout(FlowLayout.LEFT));
controlPanel1.add(actionPanel1);
topPanel = new JPanel(new BorderLayout(0, 0));
topPanel.setBorder(new BorderUIResource.EmptyBorderUIResource(new java.awt.Insets(0, 0, 6, 0)));
topPanel.add(new JLabel("Trace Files:"), BorderLayout.NORTH);
topPanel.add(scrollPane1, BorderLayout.CENTER);
topPanel.add(controlPanel1, BorderLayout.SOUTH);
layerTableModel = new LayerTableModel();
layerTable = new JTable(layerTableModel) {
// Implement table header tool tips.
protected JTableHeader createDefaultTableHeader() {
return new JTableHeader(columnModel) {
public String getToolTipText(MouseEvent e) {
java.awt.Point p = e.getPoint();
int index = columnModel.getColumnIndexAtX(p.x);
int realIndex = columnModel.getColumn(index).getModelIndex();
return columnToolTips[realIndex];
}
};
}
};
layerTable.getColumnModel().getColumn(0).setPreferredWidth(150);
layerTable.getColumnModel().getColumn(0).setCellRenderer(renderer);
layerTable.getColumnModel().getColumn(1).setPreferredWidth(70);
layerTable.getColumnModel().getColumn(1).setCellRenderer(renderer);
// layerTable.getColumnModel().getColumn(2).setPreferredWidth(70);
// layerTable.getColumnModel().getColumn(2).setCellRenderer(renderer);
// ComboBoxRenderer comboBoxRenderer = new ComboBoxRenderer(TraceFactory.TraceType.values());
// comboBoxRenderer.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE);
// layerTable.getColumnModel().getColumn(3).setPreferredWidth(20);
// layerTable.getColumnModel().getColumn(3).setCellRenderer(renderer);
layerTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
layerTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent evt) {
layerTableSelectionChanged();
}
});
TableEditorStopper.ensureEditingStopWhenTableLosesFocus(layerTable);
JScrollPane scrollPane2 = new JScrollPane(layerTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
JPanel bottomPanel = new JPanel(new BorderLayout(0, 0));
bottomPanel.add(new JLabel("Layers:"), BorderLayout.NORTH);
bottomPanel.add(scrollPane2, BorderLayout.CENTER);
JPanel leftPanel = new JPanel(new BorderLayout(0, 0));
leftPanel.setPreferredSize(new Dimension(400, 300));
splitPane1 = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true, topPanel, bottomPanel);
splitPane1.setBorder(null);
JPanel progressPanel = new JPanel(new BorderLayout(0, 0));
progressLabel = new JLabel("");
progressBar = new JProgressBar();
progressPanel.add(progressLabel, BorderLayout.NORTH);
progressPanel.add(progressBar, BorderLayout.CENTER);
progressPanel.setBorder(new BorderUIResource.EmptyBorderUIResource(new java.awt.Insets(6, 0, 0, 0)));
leftPanel.add(splitPane1, BorderLayout.CENTER);
leftPanel.add(progressPanel, BorderLayout.SOUTH);
leftPanel.setBorder(new BorderUIResource.EmptyBorderUIResource(new java.awt.Insets(12, 12, 12, 6)));
JSplitPane splitPane2 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, leftPanel, mapperPanel);
splitPane2.setBorder(null);
splitPane2.setDividerLocation(350);
Color focusColor = UIManager.getColor("Focus.color");
Border focusBorder = BorderFactory.createMatteBorder(2, 2, 2, 2, focusColor);
splitPane1.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
new FileDrop(null, splitPane1, focusBorder, new FileDrop.Listener() {
public void filesDropped(java.io.File[] files) {
importFiles(files);
}
});
// end FileDrop.Listener
getContentPane().setLayout(new java.awt.BorderLayout(0, 0));
getContentPane().add(splitPane2, BorderLayout.CENTER);
splitPane1.setDividerLocation(2000);
}
Aggregations