root / branches / v2_0_0_prep / libraries / org.gvsig.symbology / org.gvsig.symbology.swing / org.gvsig.symbology.swing.api / src / main / java / org / gvsig / app / project / documents / gui / TableSymbolCellRenderer.java @ 34291
History | View | Annotate | Download (2.92 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*
|
19 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Ib??ez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* IVER T.I. S.A
|
34 |
* Salamanca 50
|
35 |
* 46005 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963163400
|
39 |
* dac@iver.es
|
40 |
*/
|
41 |
package org.gvsig.app.project.documents.gui; |
42 |
|
43 |
import java.awt.Component; |
44 |
|
45 |
import javax.swing.BorderFactory; |
46 |
import javax.swing.JPanel; |
47 |
import javax.swing.JTable; |
48 |
import javax.swing.border.Border; |
49 |
import javax.swing.table.TableCellRenderer; |
50 |
|
51 |
import org.gvsig.app.gui.styling.SymbolPreviewer; |
52 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
53 |
|
54 |
|
55 |
|
56 |
/**
|
57 |
* Renderer de la edici?n de un registro de la tabla de s?mbolos.
|
58 |
*
|
59 |
* @author fjp
|
60 |
*/
|
61 |
public class TableSymbolCellRenderer extends JPanel implements TableCellRenderer { |
62 |
/**
|
63 |
*
|
64 |
*/
|
65 |
private static final long serialVersionUID = -1340848936814244749L; |
66 |
private Border unselectedBorder = null; |
67 |
private Border selectedBorder = null; |
68 |
private boolean isBordered = true; |
69 |
protected SymbolPreviewer preview = new SymbolPreviewer() ; |
70 |
|
71 |
/**
|
72 |
* Crea un nuevo FCellRenderer.
|
73 |
*
|
74 |
* @param isBordered DOCUMENT ME!
|
75 |
*/
|
76 |
public TableSymbolCellRenderer(boolean isBordered) { |
77 |
this.isBordered = isBordered;
|
78 |
setOpaque(true); //MUST do this for background to show up. |
79 |
} |
80 |
|
81 |
public Component getTableCellRendererComponent(JTable table, Object value, |
82 |
boolean isSelected, boolean hasFocus, int row, int column) { |
83 |
preview.setSymbol((ISymbol) value); |
84 |
|
85 |
|
86 |
if (isSelected) {
|
87 |
preview.setBackground(table.getBackground()); |
88 |
setBackground(table.getBackground()); |
89 |
} |
90 |
|
91 |
if (isBordered) {
|
92 |
if (isSelected) {
|
93 |
if (selectedBorder == null) { |
94 |
selectedBorder = BorderFactory.createMatteBorder(2, 5, 2, |
95 |
5, table.getSelectionBackground());
|
96 |
} |
97 |
setBorder(selectedBorder); |
98 |
} else {
|
99 |
if (unselectedBorder == null) { |
100 |
unselectedBorder = BorderFactory.createMatteBorder(2, 5, 2, |
101 |
5, table.getBackground());
|
102 |
} |
103 |
setBorder(unselectedBorder); |
104 |
} |
105 |
} |
106 |
|
107 |
return preview;
|
108 |
} |
109 |
|
110 |
|
111 |
|
112 |
} |
113 |
|