Statistics
| Revision:

root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / styling / MultiShapeSymbolSelector.java @ 24986

History | View | Annotate | Download (4.31 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.styling;
42

    
43
import java.awt.BorderLayout;
44
import java.awt.event.ActionEvent;
45
import java.awt.event.ActionListener;
46

    
47
import javax.swing.JPanel;
48
import javax.swing.JTabbedPane;
49

    
50
import com.iver.andami.PluginServices;
51
import com.iver.andami.ui.mdiManager.WindowInfo;
52
import com.iver.cit.gvsig.fmap.core.FShape;
53
import com.iver.cit.gvsig.fmap.core.symbols.IFillSymbol;
54
import com.iver.cit.gvsig.fmap.core.symbols.ILineSymbol;
55
import com.iver.cit.gvsig.fmap.core.symbols.IMarkerSymbol;
56
import com.iver.cit.gvsig.fmap.core.symbols.MultiShapeSymbol;
57
import com.iver.cit.gvsig.project.documents.view.legend.gui.ISymbolSelector;
58

    
59
/**
60
 * @author jaume dominguez faus - jaume.dominguez@iver.es
61
 */
62
public class MultiShapeSymbolSelector extends JPanel implements ISymbolSelector {
63
        private SymbolSelector markerSelector;
64
        private SymbolSelector lineSelector;
65
        private SymbolSelector fillSelector;
66
        private WindowInfo wi;
67
        private JTabbedPane tabbedPane;
68
        private MultiShapeSymbol sym;
69

    
70
        MultiShapeSymbolSelector(Object currSymbol) {
71
                sym = (MultiShapeSymbol) currSymbol;
72
                markerSelector = (SymbolSelector) SymbolSelector.
73
                                                        createSymbolSelector(
74
                                                                        sym.getMarkerSymbol(), FShape.POINT);
75

    
76
                lineSelector = (SymbolSelector) SymbolSelector.
77
                                                        createSymbolSelector(
78
                                                                        sym.getLineSymbol(), FShape.LINE);
79
                fillSelector = (SymbolSelector) SymbolSelector.
80
                                                        createSymbolSelector(
81
                                                                        sym.getFillSymbol(), FShape.POLYGON);
82
                initialize();
83
        }
84

    
85

    
86
        private void initialize() {
87
                setLayout(new BorderLayout());
88
                add(getJTabbedPane(), BorderLayout.CENTER);
89
        }
90

    
91

    
92
        private JTabbedPane getJTabbedPane() {
93
                if (tabbedPane == null) {
94
                        tabbedPane = new JTabbedPane();
95
                        tabbedPane.addTab(PluginServices.getText(this, "marker"), markerSelector);
96
                        tabbedPane.addTab(PluginServices.getText(this, "line"), lineSelector);
97
                        tabbedPane.addTab(PluginServices.getText(this, "fill"), fillSelector);
98
                        tabbedPane.setPreferredSize(getWindowInfo().getMinimumSize());
99
                }
100

    
101
                return tabbedPane;
102
        }
103

    
104

    
105
        public Object getSelectedObject() {
106
                MultiShapeSymbol symSel= new MultiShapeSymbol();
107
                if(markerSelector.accepted)
108
                        symSel.setMarkerSymbol((IMarkerSymbol) markerSelector.getSelectedObject());
109
                else
110
                        symSel.setMarkerSymbol(sym.getMarkerSymbol());
111
                if(lineSelector.accepted)
112
                        symSel.setLineSymbol((ILineSymbol) lineSelector.getSelectedObject());
113
                else
114
                        symSel.setLineSymbol(sym.getLineSymbol());
115
                if(fillSelector.accepted)
116
                        symSel.setFillSymbol((IFillSymbol) fillSelector.getSelectedObject());
117
                else
118
                        symSel.setFillSymbol(sym.getFillSymbol());
119

    
120
                return symSel;
121
        }
122

    
123
        public void setSymbol(Object symbol) {
124
                MultiShapeSymbol sym = (MultiShapeSymbol) symbol;
125
                markerSelector.setSymbol(sym.getMarkerSymbol());
126
                lineSelector.setSymbol(sym.getLineSymbol());
127
                fillSelector.setSymbol(sym.getFillSymbol());
128
        }
129

    
130
        public WindowInfo getWindowInfo() {
131
                if (wi == null) {
132
                        wi = new WindowInfo(WindowInfo.MODALDIALOG | WindowInfo.RESIZABLE);
133
                        wi.setWidth(706);
134
                        wi.setHeight(500);
135
                        wi.setTitle(PluginServices.getText(this, "symbol_selector"));
136
                }
137
                return wi;
138
        }
139

    
140

    
141
        public Object getWindowProfile() {
142
                return WindowInfo.DIALOG_PROFILE;
143
        }
144

    
145

    
146
}