Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.app / org.gvsig.app.mainplugin / src / main / java / org / gvsig / app / project / documents / view / toolListeners / snapping / gui / DrawSnapCellRenderer.java @ 40558

History | View | Annotate | Download (2.34 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.view.toolListeners.snapping.gui;
25

    
26
import java.awt.Color;
27
import java.awt.Component;
28
import java.awt.Graphics;
29
import java.awt.geom.Point2D;
30

    
31
import javax.swing.JPanel;
32
import javax.swing.JTable;
33
import javax.swing.table.TableCellRenderer;
34

    
35
import org.gvsig.fmap.mapcontrol.MapControlLocator;
36
import org.gvsig.fmap.mapcontrol.MapControlManager;
37
import org.gvsig.fmap.mapcontrol.PrimitivesDrawer;
38
import org.gvsig.fmap.mapcontrol.impl.DefaultPrimitivesDrawer;
39

    
40
/**
41
 * Cell Renderer del s?mbolo de cada uno de los ISnapper.
42
 *
43
 * @author Vicente Caballero Navarro
44
 */
45
public class DrawSnapCellRenderer extends JPanel implements TableCellRenderer {
46
        private static Point2D position = new Point2D.Double(7,7);
47
        private static MapControlManager mapControlManager = MapControlLocator.getMapControlManager();
48
        private PrimitivesDrawer primitivesDrawer = new DefaultPrimitivesDrawer();
49
        
50
        private int row;
51
        public DrawSnapCellRenderer() {
52
                this.setBackground(Color.white);
53
        }
54
        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
55
                this.row=row;
56
                return this;
57
        }
58
        protected void paintComponent(Graphics g) {
59
                super.paintComponent(g);
60
                
61
                primitivesDrawer.setGraphics(g);
62
                
63
                (mapControlManager.getSnapperAt(row)).draw(primitivesDrawer, position);
64
        }
65

    
66

    
67
}