Debian Codegraph @

src/dr/app/bss/TaxaPanel.java

raw symbols SCIP
1 /*
2 * TaxaPanel.java
3 *
4 * Copyright (c) 2002-2015 Alexei Drummond, Andrew Rambaut and Marc Suchard
5 *
6 * This file is part of BEAST.
7 * See the NOTICE file distributed with this work for additional
8 * information regarding copyright ownership and licensing.
9 *
10 * BEAST is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License as
12 * published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
14 *
15 * BEAST is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with BEAST; if not, write to the
22 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23 * Boston, MA 02110-1301 USA
24 */
25
26 package dr.app.bss;
27
28 import jam.framework.Exportable;
29 import jam.table.HeaderRenderer;
30 import jam.table.TableRenderer;
31
32 import java.awt.BorderLayout;
33 import java.awt.Insets;
34
35 import javax.swing.JComponent;
36 import javax.swing.JPanel;
37 import javax.swing.JScrollPane;
38 import javax.swing.JTable;
39 import javax.swing.SwingConstants;
40 import javax.swing.plaf.BorderUIResource;
41 import javax.swing.table.TableColumn;
42
43 import dr.app.gui.table.TableEditorStopper;
44
45 /**
46 * @author Filip Bielejec
47 * @version $Id$
48 */
49 @SuppressWarnings("serial")
50 public class TaxaPanel extends JPanel implements Exportable {
51
52 private PartitionDataList dataList = null;
53
54 private JScrollPane scrollPane = new JScrollPane();
55 private JTable taxaTable = null;
56 private TaxaTableModel taxaTableModel = null;
57 private TableColumn column;
58
59 public TaxaPanel(PartitionDataList dataList) {
60
61 this.dataList = dataList;
62
63 taxaTable = new JTable();
64
65 taxaTableModel = new TaxaTableModel(this.dataList);
66 taxaTable.setModel(taxaTableModel);
67
68 setLayout(new BorderLayout());
69
70 taxaTable.getTableHeader().setReorderingAllowed(false);
71
72 taxaTable.getTableHeader()
73 .setDefaultRenderer(
74 new HeaderRenderer(SwingConstants.LEFT, new Insets(0,
75 2, 0, 2)));
76
77 column = taxaTable.getColumnModel()
78 .getColumn(TaxaTableModel.NAME_INDEX);
79 column.setCellRenderer(new TableRenderer(SwingConstants.LEFT,
80 new Insets(0, 2, 0, 2)));
81 column.setPreferredWidth(80);
82
83 column = taxaTable.getColumnModel().getColumn(
84 TaxaTableModel.HEIGHT_INDEX);
85 column.setCellRenderer(new TableRenderer(SwingConstants.LEFT,
86 new Insets(0, 2, 0, 2)));
87 column.setPreferredWidth(80);
88
89 column = taxaTable.getColumnModel().getColumn(
90 TaxaTableModel.TAXA_SET_INDEX);
91 column.setCellRenderer(new TableRenderer(SwingConstants.LEFT,
92 new Insets(0, 2, 0, 2)));
93 column.setPreferredWidth(80);
94
95 TableEditorStopper.ensureEditingStopWhenTableLosesFocus(taxaTable);
96
97 scrollPane = new JScrollPane(taxaTable,
98 JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
99 JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
100
101 RowNumberTable rowNumberTable = new RowNumberTable(taxaTable);
102 scrollPane.setRowHeaderView(rowNumberTable);
103 scrollPane.setCorner(JScrollPane.UPPER_LEFT_CORNER,
104 rowNumberTable.getTableHeader());
105
106 scrollPane.getViewport().setOpaque(false);
107
108 setOpaque(false);
109 setBorder(new BorderUIResource.EmptyBorderUIResource(
110 new java.awt.Insets(12, 12, 12, 12)));
111 setLayout(new BorderLayout(0, 0));
112
113 add(scrollPane, BorderLayout.CENTER);
114
115 }// END: Constructor
116
117 public JComponent getExportableComponent() {
118 return taxaTable;
119 }
120
121 public void updateTaxaTable(PartitionDataList dataList) {
122 taxaTableModel.setDataList(dataList);
123 setDataList(dataList);
124 fireTaxaChanged();
125 }// END: updateTaxaTable
126
127 public void fireTaxaChanged() {
128 taxaTableModel.fireTaxaChanged();
129 }// END: fireTableDataChanged
130
131 public void setDataList(PartitionDataList dataList) {
132 this.dataList = dataList;
133 }// END: setDataList
134
135 }// END: class