Statistics
| Revision:

root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / view / legend / edition / gui / FCellSymbolRenderer.java @ 10679

History | View | Annotate | Download (3.21 KB)

1
/*
2
 * Created on 27-abr-2004
3
 *
4
 */
5
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
6
 *
7
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
8
 *
9
 * This program is free software; you can redistribute it and/or
10
 * modify it under the terms of the GNU General Public License
11
 * as published by the Free Software Foundation; either version 2
12
 * of the License, or (at your option) any later version.
13
 *
14
 * This program is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 * GNU General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU General Public License
20
 * along with this program; if not, write to the Free Software
21
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
22
 *
23
 * For more information, contact:
24
 *
25
 *  Generalitat Valenciana
26
 *   Conselleria d'Infraestructures i Transport
27
 *   Av. Blasco Ib??ez, 50
28
 *   46010 VALENCIA
29
 *   SPAIN
30
 *
31
 *      +34 963862235
32
 *   gvsig@gva.es
33
 *      www.gvsig.gva.es
34
 *
35
 *    or
36
 *
37
 *   IVER T.I. S.A
38
 *   Salamanca 50
39
 *   46005 Valencia
40
 *   Spain
41
 *
42
 *   +34 963163400
43
 *   dac@iver.es
44
 */
45
package com.iver.cit.gvsig.project.documents.view.legend.edition.gui;
46

    
47
import java.awt.Component;
48

    
49
import javax.swing.BorderFactory;
50
import javax.swing.JPanel;
51
import javax.swing.JTable;
52
import javax.swing.border.Border;
53
import javax.swing.table.TableCellRenderer;
54

    
55
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol;
56
import com.iver.cit.gvsig.gui.styling.SymbolPreviewer;
57

    
58

    
59
/**
60
 * Renderer de la edici?n de un registro de la tabla de s?mbolos.
61
 *
62
 * @author fjp
63
 */
64
public class FCellSymbolRenderer extends JPanel implements TableCellRenderer {
65
        Border unselectedBorder = null;
66
        Border selectedBorder = null;
67
        boolean isBordered = true;
68
        protected SymbolPreviewer preview = new SymbolPreviewer();
69

    
70
        /**
71
         * Crea un nuevo FCellRenderer.
72
         *
73
         * @param isBordered DOCUMENT ME!
74
         */
75
        public FCellSymbolRenderer(boolean isBordered) {
76
                this.isBordered = isBordered;
77
                setOpaque(true); //MUST do this for background to show up.
78
        }
79

    
80
        /**
81
         * DOCUMENT ME!
82
         *
83
         * @param table DOCUMENT ME!
84
         * @param value DOCUMENT ME!
85
         * @param isSelected DOCUMENT ME!
86
         * @param hasFocus DOCUMENT ME!
87
         * @param row DOCUMENT ME!
88
         * @param column DOCUMENT ME!
89
         *
90
         * @return DOCUMENT ME!
91
         */
92
        public Component getTableCellRendererComponent(JTable table, Object value,
93
                boolean isSelected, boolean hasFocus, int row, int column) {
94
                // System.out.println(value.getClass().toString());
95
                preview.setSymbol((ISymbol) value);
96

    
97
                // Color newColor = m_FSymbol.m_Color;
98
                // setBackground(newColor);
99
                if (isBordered) {
100
                        if (isSelected) {
101
                                if (selectedBorder == null) {
102
                                        selectedBorder = BorderFactory.createMatteBorder(2, 5, 2,
103
                                                        5, table.getSelectionBackground());
104
                                }
105

    
106
                                setBorder(selectedBorder);
107
                        } else {
108
                                if (unselectedBorder == null) {
109
                                        unselectedBorder = BorderFactory.createMatteBorder(2, 5, 2,
110
                                                        5, table.getBackground());
111
                                }
112

    
113
                                setBorder(unselectedBorder);
114
                        }
115
                }
116

    
117
                // setToolTipText("RGB value: " + newColor.getRed() + ", " + newColor.getGreen() + ", " + newColor.getBlue());
118
                return preview;
119
        }
120
}