Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.symbology / org.gvsig.symbology.swing / org.gvsig.symbology.swing.api / src / main / java / org / gvsig / app / project / documents / gui / TableSymbolCellRenderer.java @ 40560

History | View | Annotate | Download (2.67 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.app.project.documents.gui;
25

    
26
import java.awt.Component;
27

    
28
import javax.swing.BorderFactory;
29
import javax.swing.JPanel;
30
import javax.swing.JTable;
31
import javax.swing.border.Border;
32
import javax.swing.table.TableCellRenderer;
33

    
34
import org.gvsig.app.gui.styling.SymbolPreviewer;
35
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
36

    
37

    
38

    
39
/**
40
 * Renderer de la edici?n de un registro de la tabla de s?mbolos.
41
 *
42
 * @author fjp
43
 */
44
public class TableSymbolCellRenderer extends JPanel implements TableCellRenderer {
45
        /**
46
         * 
47
         */
48
        private static final long serialVersionUID = -1340848936814244749L;
49
        private Border unselectedBorder = null;
50
        private Border selectedBorder = null;
51
        private boolean isBordered = true;
52
        protected SymbolPreviewer preview = new SymbolPreviewer() ;
53
        
54
        /**
55
         * Crea un nuevo FCellRenderer.
56
         *
57
         * @param isBordered DOCUMENT ME!
58
         */
59
        public TableSymbolCellRenderer(boolean isBordered) {
60
                this.isBordered = isBordered;
61
                setOpaque(true); //MUST do this for background to show up.
62
        }
63
        
64
        public Component getTableCellRendererComponent(JTable table, Object value,
65
                boolean isSelected, boolean hasFocus, int row, int column) {
66
                preview.setSymbol((ISymbol) value);
67

    
68
                
69
                if (isSelected) {
70
                        preview.setBackground(table.getBackground());
71
                        setBackground(table.getBackground());
72
                }
73
                
74
                if (isBordered) {
75
                        if (isSelected) {
76
                                if (selectedBorder == null) {
77
                                        selectedBorder = BorderFactory.createMatteBorder(2, 5, 2,
78
                                                        5, table.getSelectionBackground());
79
                                }
80
                                setBorder(selectedBorder);
81
                        } else {
82
                                if (unselectedBorder == null) {
83
                                        unselectedBorder = BorderFactory.createMatteBorder(2, 5, 2,
84
                                                        5, table.getBackground());
85
                                }
86
                                setBorder(unselectedBorder);
87
                        }
88
                }
89
                
90
                return preview;
91
        }
92

    
93
        
94

    
95
}
96