gvsig-3d / 2.0 / trunk / org.gvsig.gvsig3d.app / org.gvsig.gvsig3d.app.extension / src / main / java / org / gvsig / gvsig3d / app / gui / styling / SimpleSymbolTab.java @ 342
History | View | Annotate | Download (5.05 KB)
1 |
package org.gvsig.gvsig3d.app.gui.styling; |
---|---|
2 |
|
3 |
import java.awt.BorderLayout; |
4 |
import java.awt.Color; |
5 |
import java.awt.Component; |
6 |
import java.awt.Dimension; |
7 |
import java.awt.FlowLayout; |
8 |
import java.awt.GridBagConstraints; |
9 |
import java.awt.GridBagLayout; |
10 |
import java.awt.GridLayout; |
11 |
import java.awt.Insets; |
12 |
import java.awt.event.ActionEvent; |
13 |
import java.awt.event.ActionListener; |
14 |
|
15 |
import javax.swing.JButton; |
16 |
import javax.swing.JColorChooser; |
17 |
import javax.swing.JComboBox; |
18 |
import javax.swing.JLabel; |
19 |
import javax.swing.JPanel; |
20 |
import javax.swing.JSlider; |
21 |
import javax.swing.JSpinner; |
22 |
import javax.swing.JTabbedPane; |
23 |
import javax.swing.SpinnerNumberModel; |
24 |
import javax.swing.border.TitledBorder; |
25 |
|
26 |
import org.gvsig.app.gui.styling.SymbolPreviewer; |
27 |
import org.gvsig.gvsig3d.symbology3d.I3DSymbol; |
28 |
import org.gvsig.gvsig3d.symbology3d.marker.ISimpleMarker3DSymbol; |
29 |
import javax.swing.event.ChangeListener; |
30 |
import javax.swing.event.ChangeEvent; |
31 |
import javax.swing.border.LineBorder; |
32 |
|
33 |
|
34 |
public class SimpleSymbolTab extends JPanel implements ISymbolSelectorTab { |
35 |
|
36 |
/**
|
37 |
*
|
38 |
*/
|
39 |
private static final long serialVersionUID = 3229652368059568464L; |
40 |
|
41 |
private ISimpleMarker3DSymbol _symbol;
|
42 |
|
43 |
private JPanel _colorPanel; |
44 |
|
45 |
private Component _parent; |
46 |
|
47 |
private JSpinner sizeSpinner; |
48 |
|
49 |
private JPanel symbolPreviewPanel; |
50 |
|
51 |
/**
|
52 |
* Create the panel.
|
53 |
*/
|
54 |
public SimpleSymbolTab(Component parent) { |
55 |
setLayout(new BorderLayout(0, 0)); |
56 |
|
57 |
_parent = parent; |
58 |
_symbol = (ISimpleMarker3DSymbol) ((SymbolSelector3D) parent) |
59 |
.getSymbol(); |
60 |
|
61 |
JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP); |
62 |
tabbedPane.setPreferredSize(new Dimension(180,300)); |
63 |
add(tabbedPane, BorderLayout.CENTER);
|
64 |
|
65 |
JPanel panel = new JPanel(); |
66 |
tabbedPane.addTab("Simple Marker", null, panel, null); |
67 |
GridBagLayout gbl_panel = new GridBagLayout(); |
68 |
gbl_panel.columnWidths = new int[] { 175 }; |
69 |
gbl_panel.rowHeights = new int[] { 180, 70 }; |
70 |
gbl_panel.columnWeights = new double[] { 0.0 }; |
71 |
gbl_panel.rowWeights = new double[] { 0.0, 0.0 }; |
72 |
//panel.setPreferredSize(new Dimension(120,130));
|
73 |
panel.setLayout(gbl_panel); |
74 |
|
75 |
symbolPreviewPanel = new JPanel(); |
76 |
symbolPreviewPanel.setBorder(new TitledBorder(null, "Preview", TitledBorder.LEADING, TitledBorder.TOP, null, null)); |
77 |
GridBagConstraints gbc_previewPanel = new GridBagConstraints(); |
78 |
gbc_previewPanel.fill = GridBagConstraints.BOTH;
|
79 |
gbc_previewPanel.insets = new Insets(0, 0, 5, 5); |
80 |
gbc_previewPanel.gridx = 0;
|
81 |
gbc_previewPanel.gridy = 0;
|
82 |
panel.add(symbolPreviewPanel, gbc_previewPanel); |
83 |
symbolPreviewPanel.setLayout(new BorderLayout(0, 0)); |
84 |
//symbolPreviewPanel.setPreferredSize(new Dimension(80,80));
|
85 |
|
86 |
JPanel _simplePanel = new JPanel(); |
87 |
symbolPreviewPanel.add(_simplePanel, BorderLayout.CENTER);
|
88 |
_simplePanel.setLayout(new BorderLayout(0, 0)); |
89 |
|
90 |
SymbolPreviewer sp = new SymbolPreviewer();
|
91 |
FlowLayout flowLayout = (FlowLayout) sp.getLayout(); |
92 |
_simplePanel.add(sp, BorderLayout.CENTER);
|
93 |
sp.setSymbol(_symbol); |
94 |
|
95 |
JPanel propertiesPanel = new JPanel(); |
96 |
propertiesPanel.setBorder(new TitledBorder(new LineBorder(new Color(184, 207, 229)), "Properties", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(51, 51, 51))); |
97 |
GridBagConstraints gbc_PropertiesPanel = new GridBagConstraints(); |
98 |
gbc_PropertiesPanel.fill = GridBagConstraints.BOTH;
|
99 |
gbc_PropertiesPanel.anchor = GridBagConstraints.NORTH;
|
100 |
gbc_PropertiesPanel.ipady = 0;
|
101 |
gbc_PropertiesPanel.ipadx = 0;
|
102 |
gbc_PropertiesPanel.insets = new Insets(0, 0, 0, 0); |
103 |
gbc_PropertiesPanel.gridx = 0;
|
104 |
gbc_PropertiesPanel.gridy = 1;
|
105 |
panel.add(propertiesPanel, gbc_PropertiesPanel); |
106 |
propertiesPanel.setLayout(new GridLayout(2, 3, 3, 3)); |
107 |
|
108 |
JLabel lblColor = new JLabel("Color:"); |
109 |
propertiesPanel.add(lblColor); |
110 |
|
111 |
_colorPanel = new JPanel(); |
112 |
FlowLayout flowLayout_1 = (FlowLayout) _colorPanel.getLayout(); |
113 |
_colorPanel.setBackground(_symbol.getColor()); |
114 |
propertiesPanel.add(_colorPanel); |
115 |
|
116 |
JButton colorButton = new JButton("Select"); |
117 |
colorButton.addActionListener(new ActionListener() { |
118 |
public void actionPerformed(ActionEvent arg0) { |
119 |
|
120 |
Color newColor = JColorChooser.showDialog(SimpleSymbolTab.this, |
121 |
"Accept", _symbol.getColor());
|
122 |
|
123 |
_symbol.setColor(newColor); |
124 |
_colorPanel.setBackground(newColor); |
125 |
_colorPanel.repaint(); |
126 |
symbolPreviewPanel.repaint(); |
127 |
|
128 |
|
129 |
} |
130 |
}); |
131 |
propertiesPanel.add(colorButton); |
132 |
|
133 |
propertiesPanel.setPreferredSize(new Dimension(80,80)); |
134 |
|
135 |
JLabel lblSize = new JLabel("Size:"); |
136 |
propertiesPanel.add(lblSize); |
137 |
|
138 |
sizeSpinner = new JSpinner(); |
139 |
sizeSpinner.setModel(new SpinnerNumberModel(_symbol |
140 |
.getSize(), 1.0, 1000.0, 1.0)); |
141 |
|
142 |
sizeSpinner.addChangeListener(new ChangeListener() { |
143 |
public void stateChanged(ChangeEvent arg0) { |
144 |
|
145 |
_symbol.setSize((Double) sizeSpinner.getValue());
|
146 |
symbolPreviewPanel.repaint(); |
147 |
|
148 |
|
149 |
} |
150 |
}); |
151 |
propertiesPanel.add(sizeSpinner); |
152 |
|
153 |
|
154 |
} |
155 |
|
156 |
public I3DSymbol getNewSymbol() {
|
157 |
// TODO Auto-generated method stub
|
158 |
return _symbol;
|
159 |
} |
160 |
|
161 |
public void updatePanel(I3DSymbol symbol) { |
162 |
// TODO Auto-generated method stub
|
163 |
|
164 |
} |
165 |
|
166 |
public void saveParameters() { |
167 |
// TODO Auto-generated method stub
|
168 |
|
169 |
} |
170 |
|
171 |
} |