1 /***
2 * TableColorModel.java
3 *
4 * This file is part of the creme library.
5 * The creme library intends to ease the development effort of large
6 * applications by providing easy to use support classes.
7 *
8 * Copyright (C) 2002 Denis Bregeon
9 *
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
14 *
15 * This library 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 GNU
18 * 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 this library; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *
24 * contact information: dbregeon@sourceforge.net
25 */
26 package org.jcreme.swing.table;
27
28 import java.awt.Color;
29 import java.util.EventListener;
30
31 import javax.swing.table.TableModel;
32
33 /***
34 * This class enables to set the color scheme for a JColoredTable. It can give a
35 * different color for the background and the foreground of any cell. A typical
36 * use is to implement a consistent color scheme whatever the renderer are.
37 *
38 * @author $Author: dbregeon $
39 * @version $Revision: 1.2 $
40 */
41 public interface TableColorModel {
42 /***
43 * Gives access to the background color of a cell.
44 *
45 * @param row
46 * the cell's row.
47 * @param column
48 * the cell's column.
49 * @param selected
50 * whether the cell is currently selected or not.
51 * @param renderer
52 * @return the background color for the cell.
53 */
54 Color getBackgroundColor(int row, int column, boolean selected,
55 java.awt.Component renderer);
56
57 /***
58 * Gives access to the foreground color of a cell.
59 *
60 * @param row
61 * the cell's row.
62 * @param column
63 * the cell's column.
64 * @param selected
65 * whether the cell is currently selected or not.
66 * @param renderer
67 * @return the foreground color for the cell.
68 */
69 Color getForegroundColor(int row, int column, boolean selected,
70 java.awt.Component renderer);
71
72 /***
73 * Enables to add listeners for the modifications of the color scheme.
74 *
75 * @param listener
76 * the listener to add.
77 */
78 void addTableColorModelListener(TableColorModelListener listener);
79
80 /***
81 * Unregisters the listener for the modifications of the color model.
82 *
83 * @param listener
84 * the listener to remove.
85 */
86 void removeTableColorModelListener(TableColorModelListener listener);
87
88 /***
89 * Gets the list of the listeners registered for the modifications of the
90 * color scheme.
91 *
92 * @param listenerType
93 * The class of listeners to retrieve.
94 * @return The list of all listeners of the given type registered in the
95 * list.
96 */
97 EventListener[] getListeners(Class listenerType);
98
99 /***
100 * Sets the model that will be colored by this TableColorModel.
101 * @param model the data to be colored by this model.
102 */
103 void setTableModel(TableModel model);
104
105 /***
106 * Gives access to the TableModel colored by this TableColorModel.
107 * @return the data colored by this model.
108 */
109 TableModel getTableModel();
110 }