Statistics
| Revision:

root / branches / v2_0_0_prep / libraries / org.gvsig.symbology / org.gvsig.symbology.swing / org.gvsig.symbology.swing.api / src / main / java / org / gvsig / app / gui / styling / MultiShapeSymbolSelector.java @ 34294

History | View | Annotate | Download (4.25 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.ui.mdiManager.WindowInfo;
49
import org.gvsig.app.project.documents.view.legend.gui.ISymbolSelector;
50
import org.gvsig.fmap.geom.Geometry;
51
import org.gvsig.i18n.Messages;
52
import org.gvsig.symbology.SymbologyLocator;
53
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.IMultiShapeSymbol;
54
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.IFillSymbol;
55
//import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.impl.MultiShapeSymbol;
56
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.line.ILineSymbol;
57
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.marker.IMarkerSymbol;
58

    
59

    
60
/**
61
 * @author jaume dominguez faus - jaume.dominguez@iver.es
62
 */
63
public class MultiShapeSymbolSelector extends JPanel implements ISymbolSelector {
64
        /**
65
         * 
66
         */
67
        private static final long serialVersionUID = 3967550608736418084L;
68
        private SymbolSelector markerSelector;
69
        private SymbolSelector lineSelector;
70
        private SymbolSelector fillSelector;
71
        private WindowInfo wi;
72
        private JTabbedPane tabbedPane;
73

    
74
        MultiShapeSymbolSelector(Object currSymbol) {
75
                IMultiShapeSymbol sym = (IMultiShapeSymbol) currSymbol;
76
                markerSelector = (SymbolSelector) SymbolSelector.
77
                                                        createSymbolSelector(
78
                                                                        sym.getMarkerSymbol(), Geometry.TYPES.POINT);
79
                lineSelector = (SymbolSelector) SymbolSelector.
80
                                                        createSymbolSelector(
81
                                                                        sym.getLineSymbol(), Geometry.TYPES.CURVE);
82
                fillSelector = (SymbolSelector) SymbolSelector.
83
                                                        createSymbolSelector(
84
                                                                        sym.getFillSymbol(), Geometry.TYPES.SURFACE);
85
                initialize();
86
        }
87

    
88

    
89
        private void initialize() {
90
                setLayout(new BorderLayout());
91
                add(getJTabbedPane(), BorderLayout.CENTER);
92
        }
93

    
94

    
95
        private JTabbedPane getJTabbedPane() {
96
                if (tabbedPane == null) {
97
                        tabbedPane = new JTabbedPane();
98
                        tabbedPane.addTab(Messages.getText("marker"), markerSelector);
99
                        tabbedPane.addTab(Messages.getText("line"), lineSelector);
100
                        tabbedPane.addTab(Messages.getText("fill"), fillSelector);
101
                        tabbedPane.setPreferredSize(getWindowInfo().getMinimumSize());
102
                }
103

    
104
                return tabbedPane;
105
        }
106

    
107

    
108
        public Object getSelectedObject() {
109
                IMultiShapeSymbol sym = SymbologyLocator.getSymbologyManager().createMultiShapeSymbol();
110
                sym.setMarkerSymbol((IMarkerSymbol) markerSelector.getSelectedObject());
111
                sym.setLineSymbol((ILineSymbol) lineSelector.getSelectedObject());
112
                sym.setFillSymbol((IFillSymbol) fillSelector.getSelectedObject());
113
                return sym;
114
        }
115

    
116
        public void setSymbol(Object symbol) {
117
                IMultiShapeSymbol sym = (IMultiShapeSymbol) symbol;
118
                markerSelector.setSymbol(sym.getMarkerSymbol());
119
                lineSelector.setSymbol(sym.getLineSymbol());
120
                fillSelector.setSymbol(sym.getFillSymbol());
121
        }
122

    
123
        public WindowInfo getWindowInfo() {
124
                if (wi == null) {
125
                        wi = new WindowInfo(WindowInfo.MODALDIALOG | WindowInfo.RESIZABLE);
126
                        wi.setWidth(706);
127
                        wi.setHeight(500);
128
                        wi.setTitle(Messages.getText("symbol_selector"));
129
                }
130
                return wi;
131
        }
132

    
133
        public Object getWindowProfile() {
134
                return WindowInfo.DIALOG_PROFILE;
135
        }
136
}