source: trunk/gli/src/org/greenstone/gatherer/gui/metaaudit/HeaderRenderer.java@ 4421

Last change on this file since 4421 was 4366, checked in by kjdon, 21 years ago

re-tabbed the code for java

  • Property svn:keywords set to Author Date Id Revision
File size: 3.5 KB
Line 
1package org.greenstone.gatherer.gui.metaaudit;
2/**
3 *#########################################################################
4 *
5 * A component of the Gatherer application, part of the Greenstone digital
6 * library suite from the New Zealand Digital Library Project at the
7 * University of Waikato, New Zealand.
8 *
9 * <BR><BR>
10 *
11 * Author: John Thompson, Greenstone Digital Library, University of Waikato
12 *
13 * <BR><BR>
14 *
15 * Copyright (C) 1999 New Zealand Digital Library Project
16 *
17 * <BR><BR>
18 *
19 * This program is free software; you can redistribute it and/or modify
20 * it under the terms of the GNU General Public License as published by
21 * the Free Software Foundation; either version 2 of the License, or
22 * (at your option) any later version.
23 *
24 * <BR><BR>
25 *
26 * This program is distributed in the hope that it will be useful,
27 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 * GNU General Public License for more details.
30 *
31 * <BR><BR>
32 *
33 * You should have received a copy of the GNU General Public License
34 * along with this program; if not, write to the Free Software
35 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
36 *########################################################################
37 */
38import java.awt.*;
39import javax.swing.*;
40import javax.swing.table.TableCellRenderer;
41import org.greenstone.gatherer.Gatherer;
42import org.greenstone.gatherer.gui.metaaudit.MetaAuditTable;
43import org.greenstone.gatherer.util.Utility;
44/** This custom button renderer replaces the boring old column headers with clickable versions which are based on JToggleButtons.
45 * @author John Thompson, Greenstone Digital Library, University of Waikato
46 * @version 2.3
47 */
48public class HeaderRenderer
49 extends JToggleButton
50 implements TableCellRenderer {
51 /** The constructor sets up a margin around the button, and adds the filter icons.
52 * @see org.greenstone.gatherer.util.Utility
53 */
54 public HeaderRenderer() {
55 setMargin(new Insets(0,0,0,0));
56 setIcon(Utility.getImage("filter.gif"));
57 setSelectedIcon(Utility.getImage("filter-on.gif"));
58 }
59 /** Called to create the component to be used as the 'rubber-stamp' for the table cell given the follwing arguments.
60 * @param table The <strong>JTable</strong> that is asking the renderer to draw; can be <i>null</i>.
61 * @param value The value of the cell to be rendered as an <strong>Object</strong>. It is up to the specific renderer to interpret and draw the value. For example, if value is the string "true", it could be rendered as a string or it could be rendered as a check box that is checked. null is a valid value.
62 * @param isSelected <i>true</i> if the cell is to be rendered with the selection highlighted; otherwise <i>false</i>.
63 * @param hasFocus If <i>true</i>, render cell appropriately. For example, put a special border on the cell, if the cell can be edited, render in the color used to indicate editing.
64 * @param row The row index of the cell being drawn as an <i>int</i>. When drawing the header, the value of row is -1.
65 * @param column The column index of the cell being drawn as an <i>int</i>.
66 * @see org.greenstone.gatherer.gui.metaaudit.MetaAuditTable
67 */
68 public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
69 setText(value.toString());
70 MetaAuditTable temp = (MetaAuditTable) table;
71 if(temp != null) { // And it may if this is called during table init.
72 setSelected(temp.isFiltered(column));
73 }
74 return this;
75 }
76}
Note: See TracBrowser for help on using the repository browser.