svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.ui / src / main / java / org / gvsig / gui / beans / swing / treeTable / TreeTableCellRenderer.java @ 40561
History | View | Annotate | Download (4.1 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 3
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
package org.gvsig.gui.beans.swing.treeTable; |
25 |
|
26 |
import java.awt.Component; |
27 |
import java.awt.Graphics; |
28 |
|
29 |
import javax.swing.JTable; |
30 |
import javax.swing.JTree; |
31 |
import javax.swing.table.TableCellRenderer; |
32 |
import javax.swing.tree.TreeCellEditor; |
33 |
import javax.swing.tree.TreeCellRenderer; |
34 |
import javax.swing.tree.TreeModel; |
35 |
|
36 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
37 |
*
|
38 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
39 |
*
|
40 |
* This program is free software; you can redistribute it and/or
|
41 |
* modify it under the terms of the GNU General Public License
|
42 |
* as published by the Free Software Foundation; either version 2
|
43 |
* of the License, or (at your option) any later version.
|
44 |
*
|
45 |
* This program is distributed in the hope that it will be useful,
|
46 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
47 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
48 |
* GNU General Public License for more details.
|
49 |
*
|
50 |
* You should have received a copy of the GNU General Public License
|
51 |
* along with this program; if not, write to the Free Software
|
52 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
53 |
*
|
54 |
* For more information, contact:
|
55 |
*
|
56 |
* Generalitat Valenciana
|
57 |
* Conselleria d'Infraestructures i Transport
|
58 |
* Av. Blasco Ib??ez, 50
|
59 |
* 46010 VALENCIA
|
60 |
* SPAIN
|
61 |
*
|
62 |
* +34 963862235
|
63 |
* gvsig@gva.es
|
64 |
* www.gvsig.gva.es
|
65 |
*
|
66 |
* or
|
67 |
*
|
68 |
* IVER T.I. S.A
|
69 |
* Salamanca 50
|
70 |
* 46005 Valencia
|
71 |
* Spain
|
72 |
*
|
73 |
* +34 963163400
|
74 |
* dac@iver.es
|
75 |
*/
|
76 |
/* CVS MESSAGES:
|
77 |
*
|
78 |
* $Id: TreeTableCellRenderer.java 13655 2007-09-12 16:28:55Z bsanchez $
|
79 |
* $Log$
|
80 |
* Revision 1.3 2007-09-12 16:28:23 bsanchez
|
81 |
* *** empty log message ***
|
82 |
*
|
83 |
* Revision 1.2 2007/08/21 09:47:17 bsanchez
|
84 |
* - Quitados warnings en imports innecesarios
|
85 |
*
|
86 |
* Revision 1.1 2007/08/20 08:34:46 evercher
|
87 |
* He fusionado LibUI con LibUIComponents
|
88 |
*
|
89 |
* Revision 1.2 2006/10/25 14:45:52 jorpiell
|
90 |
* A?adidos los renderers al arbol
|
91 |
*
|
92 |
* Revision 1.1 2006/10/23 08:18:39 jorpiell
|
93 |
* A?adida la clase treetable
|
94 |
*
|
95 |
*
|
96 |
*/
|
97 |
/**
|
98 |
* @author Jorge Piera Llodr? (piera_jor@gva.es)
|
99 |
*/
|
100 |
public class TreeTableCellRenderer extends JTree implements TableCellRenderer { |
101 |
private static final long serialVersionUID = 1017457033135612066L; |
102 |
private int visibleRow; |
103 |
private TreeTable treeTable;
|
104 |
|
105 |
public TreeTableCellRenderer(TreeModel model,TreeTable treetable) { |
106 |
super(model);
|
107 |
this.treeTable = treetable;
|
108 |
} |
109 |
|
110 |
public TreeTableCellRenderer(TreeModel model,TreeTable treetable,TreeCellRenderer cellRenderer,TreeCellEditor cellEditor){ |
111 |
super(model);
|
112 |
this.setCellRenderer(cellRenderer);
|
113 |
this.setCellEditor(cellEditor);
|
114 |
this.treeTable = treetable;
|
115 |
} |
116 |
|
117 |
public void setBounds(int x, int y, int w, int h) { |
118 |
super.setBounds(x, 0, w, treeTable.getHeight()); |
119 |
} |
120 |
|
121 |
public void paint(Graphics g) { |
122 |
g.translate(0, -visibleRow * getRowHeight());
|
123 |
super.paint(g);
|
124 |
} |
125 |
|
126 |
public Component getTableCellRendererComponent(JTable table, |
127 |
Object value,
|
128 |
boolean isSelected,
|
129 |
boolean hasFocus,
|
130 |
int row, int column) { |
131 |
if(isSelected)
|
132 |
setBackground(table.getSelectionBackground()); |
133 |
else
|
134 |
setBackground(table.getBackground()); |
135 |
|
136 |
visibleRow = row; |
137 |
return this; |
138 |
} |
139 |
} |