Statistics
| Revision:

svn-gvsig-desktop / trunk / extensions / extCAD / src / com / iver / cit / gvsig / gui / cad / snapping / panels / SnapConfig.java @ 5261

History | View | Annotate | Download (4.73 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 com.iver.cit.gvsig.gui.cad.snapping.panels;
42

    
43
import java.awt.Component;
44
import java.util.ArrayList;
45

    
46
import javax.swing.ImageIcon;
47
import javax.swing.JCheckBox;
48
import javax.swing.JLabel;
49
import javax.swing.JList;
50
import javax.swing.JPanel;
51
import javax.swing.JScrollPane;
52
import javax.swing.ListCellRenderer;
53

    
54
import com.iver.utiles.DefaultListModel;
55
;
56

    
57
public class SnapConfig extends JPanel {
58

    
59
        private JCheckBox jChkBoxRefentActive = null;
60
        private JList jListSnappers = null;
61
        private JPanel jPanel = null;
62
        private JScrollPane jScrollPane = null;
63
        
64
        private ArrayList snappers;
65
        
66
         class MyCellRenderer extends JCheckBox implements ListCellRenderer {
67

    
68
             // This is the only method defined by ListCellRenderer.
69
             // We just reconfigure the JLabel each time we're called.
70

    
71
             public Component getListCellRendererComponent(
72
               JList list,
73
               Object value,            // value to display
74
               int index,               // cell index
75
               boolean isSelected,      // is the cell selected
76
               boolean cellHasFocus)    // the list and the cell have the focus
77
             {
78
                 String s = value.toString();
79
                 setText(s);
80
                 
81
                      if (isSelected) {
82
                     setBackground(list.getSelectionBackground());
83
                       setForeground(list.getSelectionForeground());
84
                   }
85
                 else {
86
                       setBackground(list.getBackground());
87
                       setForeground(list.getForeground());
88
                   }
89
                   setEnabled(list.isEnabled());
90
                   setFont(list.getFont());
91
                 setOpaque(true);
92
                 return this;
93
             }
94
         }
95

    
96
        
97
        /**
98
         * This method initializes 
99
         * 
100
         */
101
        public SnapConfig() {
102
                super();
103
                initialize();
104
        }
105

    
106
        /**
107
         * This method initializes this
108
         * 
109
         */
110
        private void initialize() {
111
        this.setLayout(null);
112
        this.setSize(new java.awt.Dimension(463,239));
113
        this.setPreferredSize(new java.awt.Dimension(463,239));
114
        this.add(getJChkBoxRefentActive(), null);
115
        this.add(getJPanel(), null);
116
                        
117
        }
118

    
119
        /**
120
         * This method initializes jChkBoxRefentActive        
121
         *         
122
         * @return javax.swing.JCheckBox        
123
         */
124
        private JCheckBox getJChkBoxRefentActive() {
125
                if (jChkBoxRefentActive == null) {
126
                        jChkBoxRefentActive = new JCheckBox();
127
                        jChkBoxRefentActive.setText("Referencia a Objetos Activada:");
128
                        jChkBoxRefentActive.setBounds(new java.awt.Rectangle(26,10,418,23));
129
                }
130
                return jChkBoxRefentActive;
131
        }
132

    
133
        /**
134
         * This method initializes jListSnappers        
135
         *         
136
         * @return javax.swing.JList        
137
         */
138
        private JList getJListSnappers() {
139
                if (jListSnappers == null) {
140
                        jListSnappers = new JList();
141
                        jListSnappers.setCellRenderer(new MyCellRenderer());
142
                }
143
                return jListSnappers;
144
        }
145

    
146
        /**
147
         * This method initializes jPanel        
148
         *         
149
         * @return javax.swing.JPanel        
150
         */
151
        private JPanel getJPanel() {
152
                if (jPanel == null) {
153
                        jPanel = new JPanel();
154
                        jPanel.setLayout(null);
155
                        jPanel.setBounds(new java.awt.Rectangle(19,40,423,181));
156
                        jPanel.add(getJScrollPane(), null);
157
                }
158
                return jPanel;
159
        }
160

    
161
        /**
162
         * This method initializes jScrollPane        
163
         *         
164
         * @return javax.swing.JScrollPane        
165
         */
166
        private JScrollPane getJScrollPane() {
167
                if (jScrollPane == null) {
168
                        jScrollPane = new JScrollPane();
169
                        jScrollPane.setBounds(new java.awt.Rectangle(9,9,402,163));
170
                        jScrollPane.setViewportView(getJListSnappers());
171
                }
172
                return jScrollPane;
173
        }
174

    
175
        public ArrayList getSnappers() {
176
                return snappers;
177
        }
178

    
179
        public void setSnappers(ArrayList snappers) {
180
                this.snappers = snappers;
181
                DefaultListModel listModel = new DefaultListModel(snappers);
182
                getJListSnappers().setModel(listModel);
183
        }
184
        
185
        
186
}  //  @jve:decl-index=0:visual-constraint="10,10"
187

    
188