Statistics
| Revision:

root / branches / v2_0_0_prep / applications / appgvSIG / src / org / gvsig / app / gui / styling / MultiShapeSymbolSelector.java @ 30011

History | View | Annotate | Download (4.05 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 org.gvsig.app.gui.styling;
42

    
43
import java.awt.BorderLayout;
44

    
45
import javax.swing.JPanel;
46
import javax.swing.JTabbedPane;
47

    
48
import org.gvsig.andami.PluginServices;
49
import org.gvsig.andami.ui.mdiManager.WindowInfo;
50
import org.gvsig.app.project.documents.view.legend.gui.ISymbolSelector;
51
import org.gvsig.fmap.geom.Geometry;
52
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.IFillSymbol;
53
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.impl.MultiShapeSymbol;
54
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.line.ILineSymbol;
55
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.marker.IMarkerSymbol;
56

    
57

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

    
68
        MultiShapeSymbolSelector(Object currSymbol) {
69
                MultiShapeSymbol sym = (MultiShapeSymbol) currSymbol;
70
                markerSelector = (SymbolSelector) SymbolSelector.
71
                                                        createSymbolSelector(
72
                                                                        sym.getMarkerSymbol(), Geometry.TYPES.POINT);
73
                lineSelector = (SymbolSelector) SymbolSelector.
74
                                                        createSymbolSelector(
75
                                                                        sym.getLineSymbol(), Geometry.TYPES.CURVE);
76
                fillSelector = (SymbolSelector) SymbolSelector.
77
                                                        createSymbolSelector(
78
                                                                        sym.getFillSymbol(), Geometry.TYPES.SURFACE);
79
                initialize();
80
        }
81

    
82

    
83
        private void initialize() {
84
                setLayout(new BorderLayout());
85
                add(getJTabbedPane(), BorderLayout.CENTER);
86
        }
87

    
88

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

    
98
                return tabbedPane;
99
        }
100

    
101

    
102
        public Object getSelectedObject() {
103
                MultiShapeSymbol sym = new MultiShapeSymbol();
104
                sym.setMarkerSymbol((IMarkerSymbol) markerSelector.getSelectedObject());
105
                sym.setLineSymbol((ILineSymbol) lineSelector.getSelectedObject());
106
                sym.setFillSymbol((IFillSymbol) fillSelector.getSelectedObject());
107
                return sym;
108
        }
109

    
110
        public void setSymbol(Object symbol) {
111
                MultiShapeSymbol sym = (MultiShapeSymbol) symbol;
112
                markerSelector.setSymbol(sym.getMarkerSymbol());
113
                lineSelector.setSymbol(sym.getLineSymbol());
114
                fillSelector.setSymbol(sym.getFillSymbol());
115
        }
116

    
117
        public WindowInfo getWindowInfo() {
118
                if (wi == null) {
119
                        wi = new WindowInfo(WindowInfo.MODALDIALOG | WindowInfo.RESIZABLE);
120
                        wi.setWidth(706);
121
                        wi.setHeight(500);
122
                        wi.setTitle(PluginServices.getText(this, "symbol_selector"));
123
                }
124
                return wi;
125
        }
126

    
127
        public Object getWindowProfile() {
128
                return WindowInfo.DIALOG_PROFILE;
129
        }
130
}