Revision 39765 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
MultiShapeSymbolSelector.java | ||
---|---|---|
41 | 41 |
package org.gvsig.app.gui.styling; |
42 | 42 |
|
43 | 43 |
import java.awt.BorderLayout; |
44 |
import java.awt.Component; |
|
45 |
import java.awt.event.ActionEvent; |
|
46 |
import java.awt.event.ActionListener; |
|
44 | 47 |
|
48 |
import javax.swing.BorderFactory; |
|
49 |
import javax.swing.JButton; |
|
45 | 50 |
import javax.swing.JPanel; |
46 | 51 |
import javax.swing.JTabbedPane; |
52 |
import javax.swing.border.Border; |
|
47 | 53 |
|
54 |
import org.slf4j.Logger; |
|
55 |
import org.slf4j.LoggerFactory; |
|
56 |
|
|
57 |
import org.gvsig.andami.PluginServices; |
|
48 | 58 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
49 | 59 |
import org.gvsig.app.project.documents.view.legend.gui.ISymbolSelector; |
50 | 60 |
import org.gvsig.fmap.geom.Geometry; |
61 |
import org.gvsig.fmap.geom.Geometry.SUBTYPES; |
|
62 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
63 |
import org.gvsig.fmap.geom.GeometryManager; |
|
64 |
import org.gvsig.fmap.geom.type.GeometryType; |
|
51 | 65 |
import org.gvsig.i18n.Messages; |
52 | 66 |
import org.gvsig.symbology.SymbologyLocator; |
53 | 67 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.IMultiShapeSymbol; |
54 | 68 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.IFillSymbol; |
55 |
//import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.impl.MultiShapeSymbol; |
|
56 | 69 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.line.ILineSymbol; |
57 | 70 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.marker.IMarkerSymbol; |
71 |
import org.gvsig.tools.exception.BaseException; |
|
58 | 72 |
|
59 | 73 |
|
60 |
public class MultiShapeSymbolSelector extends JPanel implements ISymbolSelector { |
|
61 |
/** |
|
62 |
* |
|
63 |
*/ |
|
74 |
public class MultiShapeSymbolSelector extends JPanel implements |
|
75 |
ISymbolSelector, ActionListener { |
|
76 |
|
|
77 |
private static Logger logger = LoggerFactory.getLogger( |
|
78 |
MultiShapeSymbolSelector.class); |
|
79 |
|
|
64 | 80 |
private static final long serialVersionUID = 3967550608736418084L; |
65 | 81 |
private SymbolSelector markerSelector; |
66 | 82 |
private SymbolSelector lineSelector; |
67 | 83 |
private SymbolSelector fillSelector; |
68 | 84 |
private WindowInfo wi; |
69 | 85 |
private JTabbedPane tabbedPane; |
86 |
|
|
87 |
private GeometryManager gManager = null; |
|
88 |
private JButton closeButton = null; |
|
89 |
private JPanel closeButtonPanel = null; |
|
70 | 90 |
|
71 | 91 |
public static ISymbolSelector createSymbolBrowser() { |
72 | 92 |
WindowInfo winfo = new WindowInfo(WindowInfo.RESIZABLE|WindowInfo.MAXIMIZABLE|WindowInfo.ICONIFIABLE); |
73 | 93 |
winfo.setWidth(706); |
74 | 94 |
winfo.setHeight(500); |
75 | 95 |
winfo.setTitle(Messages.getText("symbols_browser")); |
76 |
return new MultiShapeSymbolSelector(winfo); |
|
96 |
MultiShapeSymbolSelector resp = null; |
|
97 |
|
|
98 |
try { |
|
99 |
/* |
|
100 |
* This instantiates a symbol browser |
|
101 |
* (a selector without accept/cancel panel) |
|
102 |
*/ |
|
103 |
resp = new MultiShapeSymbolSelector(); |
|
104 |
resp.wi = winfo; |
|
105 |
} catch (BaseException e) { |
|
106 |
logger.info("Unable to create symbol browser, will use selector.", e); |
|
107 |
resp = new MultiShapeSymbolSelector(winfo); |
|
108 |
} |
|
109 |
return resp; |
|
77 | 110 |
} |
78 | 111 |
|
112 |
/* |
|
113 |
* This instantiates a symbol browser |
|
114 |
*/ |
|
115 |
private MultiShapeSymbolSelector() throws BaseException { |
|
116 |
|
|
117 |
GeometryType |
|
118 |
gt = getGeomManager().getGeometryType(Geometry.TYPES.POINT, |
|
119 |
SUBTYPES.GEOM2D); |
|
120 |
markerSelector = new SymbolSelectorBrowser(gt, true); |
|
121 |
gt = getGeomManager().getGeometryType(Geometry.TYPES.CURVE, |
|
122 |
SUBTYPES.GEOM2D); |
|
123 |
lineSelector = new SymbolSelectorBrowser(gt, true); |
|
124 |
gt = getGeomManager().getGeometryType(Geometry.TYPES.SURFACE, |
|
125 |
SUBTYPES.GEOM2D); |
|
126 |
fillSelector = new SymbolSelectorBrowser(gt, true); |
|
127 |
|
|
128 |
initialize(true); |
|
129 |
} |
|
130 |
|
|
79 | 131 |
private MultiShapeSymbolSelector(WindowInfo wi) { |
80 | 132 |
this((Object)null); |
81 | 133 |
this.wi = wi; |
... | ... | |
101 | 153 |
.createSymbolSelector(sym.getFillSymbol(), |
102 | 154 |
Geometry.TYPES.SURFACE); |
103 | 155 |
} |
104 |
initialize(); |
|
156 |
initialize(false);
|
|
105 | 157 |
} |
106 | 158 |
|
107 | 159 |
|
108 |
private void initialize() { |
|
160 |
private void initialize(boolean add_close_button) {
|
|
109 | 161 |
setLayout(new BorderLayout()); |
110 | 162 |
add(getJTabbedPane(), BorderLayout.CENTER); |
163 |
if (add_close_button) { |
|
164 |
add(getCloseButtonPanel(), BorderLayout.SOUTH); |
|
165 |
} |
|
111 | 166 |
} |
112 | 167 |
|
113 |
|
|
114 |
private JTabbedPane getJTabbedPane() { |
|
168 |
private JTabbedPane getJTabbedPane() { |
|
115 | 169 |
if (tabbedPane == null) { |
116 | 170 |
tabbedPane = new JTabbedPane(); |
117 | 171 |
tabbedPane.addTab(Messages.getText("marker"), markerSelector); |
... | ... | |
173 | 227 |
} |
174 | 228 |
return WindowInfo.EDITOR_PROFILE; |
175 | 229 |
} |
230 |
|
|
231 |
private GeometryManager getGeomManager() { |
|
232 |
|
|
233 |
if (gManager == null) { |
|
234 |
gManager = GeometryLocator.getGeometryManager(); |
|
235 |
} |
|
236 |
return gManager; |
|
237 |
} |
|
238 |
|
|
239 |
private JButton getCloseButton() { |
|
240 |
if (closeButton == null) { |
|
241 |
String txt = Messages.getText("close"); |
|
242 |
closeButton = new JButton(txt); |
|
243 |
closeButton.addActionListener(this); |
|
244 |
} |
|
245 |
return closeButton; |
|
246 |
} |
|
247 |
|
|
248 |
private Component getCloseButtonPanel() { |
|
249 |
|
|
250 |
if (closeButtonPanel == null) { |
|
251 |
closeButtonPanel = new JPanel(); |
|
252 |
Border brd = BorderFactory.createEmptyBorder(10, 10, 10, 10); |
|
253 |
closeButtonPanel.setBorder(brd); |
|
254 |
closeButtonPanel.setLayout(new BorderLayout()); |
|
255 |
closeButtonPanel.add(getCloseButton(), BorderLayout.EAST); |
|
256 |
} |
|
257 |
return closeButtonPanel; |
|
258 |
} |
|
259 |
|
|
260 |
public void actionPerformed(ActionEvent e) { |
|
261 |
|
|
262 |
if (e.getSource() == this.getCloseButton()) { |
|
263 |
PluginServices.getMDIManager().closeWindow(this); |
|
264 |
} |
|
265 |
|
|
266 |
} |
|
267 |
|
|
176 | 268 |
} |
Also available in: Unified diff