Statistics
| Revision:

gvsig-3d / 2.1 / trunk / org.gvsig.gvsig3d / org.gvsig.gvsig3d.app / org.gvsig.gvsig3d.app.commons / src / main / java / org / gvsig / gvsig3d / app / gui / styling / SimpleSymbolTab.java @ 385

History | View | Annotate | Download (6.3 KB)

1
/* gvSIG 3D extension for gvSIG
2
 *
3
 * Copyright (C) 2012 Prodevelop.
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
 *   Prodevelop, S.L.
22
 *   Pza. Don Juan de Villarrasa, 14 - 5
23
 *   46001 Valencia
24
 *   Spain
25
 *
26
 *   +34 963 510 612
27
 *   +34 963 510 968
28
 *   prode@prodevelop.es
29
 *   http://www.prodevelop.es
30
 */
31
/*
32
 * AUTHORS:
33
 * 2012 AI2 - Instituto Universitario de Automatica e Informatica Industrial.
34
 * Universitat Politecnica de Valencia (UPV)
35
 * http://www.ai2.upv.es
36
 */
37

    
38

    
39
package org.gvsig.gvsig3d.app.gui.styling;
40

    
41
import java.awt.BorderLayout;
42
import java.awt.Color;
43
import java.awt.Component;
44
import java.awt.Dimension;
45
import java.awt.FlowLayout;
46
import java.awt.GridBagConstraints;
47
import java.awt.GridBagLayout;
48
import java.awt.GridLayout;
49
import java.awt.Insets;
50
import java.awt.event.ActionEvent;
51
import java.awt.event.ActionListener;
52

    
53
import javax.swing.JButton;
54
import javax.swing.JColorChooser;
55
import javax.swing.JComboBox;
56
import javax.swing.JLabel;
57
import javax.swing.JPanel;
58
import javax.swing.JSlider;
59
import javax.swing.JSpinner;
60
import javax.swing.JTabbedPane;
61
import javax.swing.SpinnerNumberModel;
62
import javax.swing.border.TitledBorder;
63

    
64
import org.gvsig.app.gui.styling.SymbolPreviewer;
65
import org.gvsig.gvsig3d.impl.symbology3d.marker.impl.SimpleMarker3DSymbol;
66
import org.gvsig.gvsig3d.symbology3d.I3DSymbol;
67
import org.gvsig.gvsig3d.symbology3d.marker.ISimpleMarker3DSymbol;
68
import javax.swing.event.ChangeListener;
69
import javax.swing.event.ChangeEvent;
70
import javax.swing.border.LineBorder;
71

    
72
/**
73
 * @author Jesus Zarzoso- jzarzoso@ai2.upv.es
74
 * @version $Id$
75
 * 
76
 */
77
public class SimpleSymbolTab extends JPanel implements ISymbolSelectorTab {
78

    
79
        /**
80
         * 
81
         */
82
        private static final long serialVersionUID = 3229652368059568464L;
83

    
84
        private ISimpleMarker3DSymbol _symbol;
85

    
86
        private JPanel _colorPanel;
87

    
88
        private Component _parent;
89

    
90
        private JSpinner sizeSpinner;
91

    
92
        private JPanel symbolPreviewPanel;
93

    
94
        /**
95
         * Create the panel.
96
         */
97
        public SimpleSymbolTab(Component parent) {
98
                setLayout(new BorderLayout(0, 0));
99

    
100
                _parent = parent;
101
                _symbol = (ISimpleMarker3DSymbol) ((SymbolSelector3D) parent)
102
                                .getSymbol();
103

    
104
                JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
105
                // tabbedPane.setPreferredSize(new Dimension(180,300));
106
                add(tabbedPane, BorderLayout.CENTER);
107

    
108
                JPanel panel = new JPanel();
109
                tabbedPane.addTab("Marker", null, panel, null);
110
                GridBagLayout gbl_panel = new GridBagLayout();
111
                gbl_panel.columnWidths = new int[] { 175 };
112
                gbl_panel.rowHeights = new int[] { 180, 70 };
113
                gbl_panel.columnWeights = new double[] { 1.0 };
114
                gbl_panel.rowWeights = new double[] { 1.0, 1.0 };
115
                // panel.setPreferredSize(new Dimension(120,130));
116
                panel.setLayout(gbl_panel);
117

    
118
                symbolPreviewPanel = new JPanel();
119
                symbolPreviewPanel.setBorder(new TitledBorder(null, "Preview",
120
                                TitledBorder.LEADING, TitledBorder.TOP, null, null));
121
                GridBagConstraints gbc_previewPanel = new GridBagConstraints();
122
                gbc_previewPanel.fill = GridBagConstraints.BOTH;
123
                gbc_previewPanel.insets = new Insets(0, 0, 5, 5);
124
                gbc_previewPanel.gridx = 0;
125
                gbc_previewPanel.gridy = 0;
126
                panel.add(symbolPreviewPanel, gbc_previewPanel);
127
                symbolPreviewPanel.setLayout(new BorderLayout(0, 0));
128
                symbolPreviewPanel.setPreferredSize(new Dimension(120, 130));
129

    
130
                JPanel _simplePanel = new JPanel();
131
                symbolPreviewPanel.add(_simplePanel, BorderLayout.CENTER);
132
                _simplePanel.setLayout(new BorderLayout(0, 0));
133

    
134
                SymbolPreviewer sp = new SymbolPreviewer();
135
                _simplePanel.add(sp, BorderLayout.CENTER);
136
                if (!(_symbol.getClass().equals(SimpleMarker3DSymbol.class)))
137
                        _symbol = new SimpleMarker3DSymbol();
138

    
139
                sp.setSymbol(_symbol);
140

    
141
                JPanel propertiesPanel = new JPanel();
142
                propertiesPanel.setBorder(new TitledBorder(new LineBorder(new Color(
143
                                184, 207, 229)), "Properties", TitledBorder.LEADING,
144
                                TitledBorder.TOP, null, new Color(51, 51, 51)));
145
                GridBagConstraints gbc_PropertiesPanel = new GridBagConstraints();
146
                gbc_PropertiesPanel.fill = GridBagConstraints.BOTH;
147
                gbc_PropertiesPanel.anchor = GridBagConstraints.NORTH;
148
                gbc_PropertiesPanel.ipady = 0;
149
                gbc_PropertiesPanel.ipadx = 0;
150
                gbc_PropertiesPanel.insets = new Insets(0, 0, 0, 0);
151
                gbc_PropertiesPanel.gridx = 0;
152
                gbc_PropertiesPanel.gridy = 1;
153
                panel.add(propertiesPanel, gbc_PropertiesPanel);
154
                propertiesPanel.setLayout(new GridLayout(2, 3, 3, 3));
155

    
156
                JLabel lblColor = new JLabel("Color:");
157
                propertiesPanel.add(lblColor);
158

    
159
                _colorPanel = new JPanel();
160
                _colorPanel.setBackground(_symbol.getColor());
161
                propertiesPanel.add(_colorPanel);
162

    
163
                JButton colorButton = new JButton("Select");
164
                colorButton.addActionListener(new ActionListener() {
165
                        public void actionPerformed(ActionEvent arg0) {
166

    
167
                                Color newColor = JColorChooser.showDialog(SimpleSymbolTab.this,
168
                                                "Accept", _symbol.getColor());
169

    
170
                                _symbol.setColor(newColor);
171
                                _colorPanel.setBackground(newColor);
172
                                _colorPanel.repaint();
173
                                symbolPreviewPanel.repaint();
174

    
175
                        }
176
                });
177
                propertiesPanel.add(colorButton);
178

    
179
                propertiesPanel.setPreferredSize(new Dimension(80, 80));
180

    
181
                JLabel lblSize = new JLabel("Size:");
182
                propertiesPanel.add(lblSize);
183

    
184
                sizeSpinner = new JSpinner();
185
                sizeSpinner.setModel(new SpinnerNumberModel(_symbol.getSize(), 1.0,
186
                                1000.0, 1.0));
187

    
188
                sizeSpinner.addChangeListener(new ChangeListener() {
189
                        public void stateChanged(ChangeEvent arg0) {
190

    
191
                                _symbol.setSize((Double) sizeSpinner.getValue());
192
                                symbolPreviewPanel.repaint();
193

    
194
                        }
195
                });
196
                propertiesPanel.add(sizeSpinner);
197

    
198
        }
199

    
200
        public I3DSymbol getNewSymbol() {
201
                // TODO Auto-generated method stub
202
                return _symbol;
203
        }
204

    
205
        public void updatePanel(I3DSymbol symbol) {
206
                // TODO Auto-generated method stub
207

    
208
        }
209

    
210
        public void saveParameters() {
211
                // TODO Auto-generated method stub
212

    
213
        }
214

    
215
}