svn-gvsig-desktop / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / styling / MultiShapeSymbolSelector.java @ 25925
History | View | Annotate | Download (5.03 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 org.gvsig.gui.beans.AcceptCancelPanel; |
51 |
|
52 |
import com.iver.andami.PluginServices; |
53 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
54 |
import com.iver.cit.gvsig.fmap.core.FShape; |
55 |
import com.iver.cit.gvsig.fmap.core.symbols.IFillSymbol; |
56 |
import com.iver.cit.gvsig.fmap.core.symbols.ILineSymbol; |
57 |
import com.iver.cit.gvsig.fmap.core.symbols.IMarkerSymbol; |
58 |
import com.iver.cit.gvsig.fmap.core.symbols.MultiShapeSymbol; |
59 |
import com.iver.cit.gvsig.project.documents.view.legend.gui.ISymbolSelector; |
60 |
|
61 |
/**
|
62 |
* @author jaume dominguez faus - jaume.dominguez@iver.es
|
63 |
*/
|
64 |
public class MultiShapeSymbolSelector extends JPanel implements ISymbolSelector { |
65 |
private SymbolSelector markerSelector;
|
66 |
private SymbolSelector lineSelector;
|
67 |
private SymbolSelector fillSelector;
|
68 |
private WindowInfo wi;
|
69 |
private JTabbedPane tabbedPane; |
70 |
private MultiShapeSymbol sym;
|
71 |
protected AcceptCancelPanel okCancelPanel;
|
72 |
protected boolean accepted = false; |
73 |
|
74 |
MultiShapeSymbolSelector(Object currSymbol) {
|
75 |
sym = (MultiShapeSymbol) currSymbol; |
76 |
markerSelector = (SymbolSelector) SymbolSelector. |
77 |
createSymbolSelector( |
78 |
sym.getMarkerSymbol(), FShape.POINT, false);
|
79 |
|
80 |
lineSelector = (SymbolSelector) SymbolSelector. |
81 |
createSymbolSelector( |
82 |
sym.getLineSymbol(), FShape.LINE, false);
|
83 |
fillSelector = (SymbolSelector) SymbolSelector. |
84 |
createSymbolSelector( |
85 |
sym.getFillSymbol(), FShape.POLYGON, false);
|
86 |
initialize(); |
87 |
} |
88 |
|
89 |
|
90 |
private void initialize() { |
91 |
setLayout(new BorderLayout()); |
92 |
add(getJTabbedPane(), BorderLayout.CENTER);
|
93 |
|
94 |
ActionListener okAction = new ActionListener() { |
95 |
public void actionPerformed(ActionEvent e) { |
96 |
accepted = true;
|
97 |
PluginServices.getMDIManager().closeWindow(MultiShapeSymbolSelector.this); |
98 |
} |
99 |
}, cancelAction = new ActionListener() { |
100 |
public void actionPerformed(ActionEvent e) { |
101 |
accepted = false;
|
102 |
// ((SymbolPreviewer) jPanelPreview).setSymbol(null);
|
103 |
PluginServices.getMDIManager().closeWindow(MultiShapeSymbolSelector.this); |
104 |
|
105 |
} |
106 |
}; |
107 |
okCancelPanel = new AcceptCancelPanel();
|
108 |
okCancelPanel.setOkButtonActionListener(okAction); |
109 |
okCancelPanel.setCancelButtonActionListener(cancelAction); |
110 |
|
111 |
this.add(okCancelPanel, BorderLayout.SOUTH); |
112 |
} |
113 |
|
114 |
|
115 |
private JTabbedPane getJTabbedPane() { |
116 |
if (tabbedPane == null) { |
117 |
tabbedPane = new JTabbedPane(); |
118 |
tabbedPane.addTab(PluginServices.getText(this, "marker"), markerSelector); |
119 |
tabbedPane.addTab(PluginServices.getText(this, "line"), lineSelector); |
120 |
tabbedPane.addTab(PluginServices.getText(this, "fill"), fillSelector); |
121 |
tabbedPane.setPreferredSize(getWindowInfo().getMinimumSize()); |
122 |
} |
123 |
|
124 |
return tabbedPane;
|
125 |
} |
126 |
|
127 |
|
128 |
public Object getSelectedObject() { |
129 |
MultiShapeSymbol symSel= new MultiShapeSymbol();
|
130 |
if(accepted){
|
131 |
symSel.setMarkerSymbol((IMarkerSymbol) markerSelector.getSelectedObject()); |
132 |
symSel.setLineSymbol((ILineSymbol) lineSelector.getSelectedObject()); |
133 |
symSel.setFillSymbol((IFillSymbol) fillSelector.getSelectedObject()); |
134 |
}else{
|
135 |
symSel.setMarkerSymbol(sym.getMarkerSymbol()); |
136 |
symSel.setLineSymbol(sym.getLineSymbol()); |
137 |
symSel.setFillSymbol(sym.getFillSymbol()); |
138 |
} |
139 |
return symSel;
|
140 |
} |
141 |
|
142 |
public void setSymbol(Object symbol) { |
143 |
MultiShapeSymbol sym = (MultiShapeSymbol) symbol; |
144 |
markerSelector.setSymbol(sym.getMarkerSymbol()); |
145 |
lineSelector.setSymbol(sym.getLineSymbol()); |
146 |
fillSelector.setSymbol(sym.getFillSymbol()); |
147 |
} |
148 |
|
149 |
public WindowInfo getWindowInfo() {
|
150 |
if (wi == null) { |
151 |
wi = new WindowInfo(WindowInfo.MODALDIALOG | WindowInfo.RESIZABLE);
|
152 |
wi.setWidth(706);
|
153 |
wi.setHeight(500);
|
154 |
wi.setTitle(PluginServices.getText(this, "symbol_selector")); |
155 |
} |
156 |
return wi;
|
157 |
} |
158 |
|
159 |
|
160 |
public Object getWindowProfile() { |
161 |
return WindowInfo.DIALOG_PROFILE;
|
162 |
} |
163 |
|
164 |
|
165 |
} |