svn-gvsig-desktop / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / thememanager / legendmanager / panels / FPanelLegendDefault.java @ 2452
History | View | Annotate | Download (35.8 KB)
1 | 1671 | jmorell | /*
|
---|---|---|---|
2 | * Created on 30-abr-2004
|
||
3 | *
|
||
4 | * To change the template for this generated file go to
|
||
5 | * Window>Preferences>Java>Code Generation>Code and Comments
|
||
6 | */
|
||
7 | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
||
8 | *
|
||
9 | * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
||
10 | *
|
||
11 | * This program is free software; you can redistribute it and/or
|
||
12 | * modify it under the terms of the GNU General Public License
|
||
13 | * as published by the Free Software Foundation; either version 2
|
||
14 | * of the License, or (at your option) any later version.
|
||
15 | *
|
||
16 | * This program is distributed in the hope that it will be useful,
|
||
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
19 | * GNU General Public License for more details.
|
||
20 | *
|
||
21 | * You should have received a copy of the GNU General Public License
|
||
22 | * along with this program; if not, write to the Free Software
|
||
23 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||
24 | *
|
||
25 | * For more information, contact:
|
||
26 | *
|
||
27 | * Generalitat Valenciana
|
||
28 | * Conselleria d'Infraestructures i Transport
|
||
29 | * Av. Blasco Ib??ez, 50
|
||
30 | * 46010 VALENCIA
|
||
31 | * SPAIN
|
||
32 | *
|
||
33 | * +34 963862235
|
||
34 | * gvsig@gva.es
|
||
35 | * www.gvsig.gva.es
|
||
36 | *
|
||
37 | * or
|
||
38 | *
|
||
39 | * IVER T.I. S.A
|
||
40 | * Salamanca 50
|
||
41 | * 46005 Valencia
|
||
42 | * Spain
|
||
43 | *
|
||
44 | * +34 963163400
|
||
45 | * dac@iver.es
|
||
46 | */
|
||
47 | package com.iver.cit.gvsig.gui.thememanager.legendmanager.panels; |
||
48 | |||
49 | import java.awt.BasicStroke; |
||
50 | import java.awt.BorderLayout; |
||
51 | import java.awt.Color; |
||
52 | import java.awt.Component; |
||
53 | import java.awt.Dimension; |
||
54 | import java.awt.Graphics; |
||
55 | import java.awt.Graphics2D; |
||
56 | import java.awt.GridBagConstraints; |
||
57 | import java.awt.GridBagLayout; |
||
58 | import java.awt.Insets; |
||
59 | import java.awt.Paint; |
||
60 | import java.awt.event.ActionEvent; |
||
61 | import java.awt.event.ActionListener; |
||
62 | import java.awt.geom.AffineTransform; |
||
63 | import java.awt.geom.Line2D; |
||
64 | import java.awt.geom.Rectangle2D; |
||
65 | import java.io.File; |
||
66 | 2452 | fjp | import java.net.URI; |
67 | 1671 | jmorell | import java.util.List; |
68 | |||
69 | import javax.swing.BorderFactory; |
||
70 | import javax.swing.DefaultComboBoxModel; |
||
71 | import javax.swing.ImageIcon; |
||
72 | import javax.swing.JButton; |
||
73 | import javax.swing.JCheckBox; |
||
74 | import javax.swing.JComboBox; |
||
75 | import javax.swing.JFileChooser; |
||
76 | import javax.swing.JLabel; |
||
77 | import javax.swing.JList; |
||
78 | import javax.swing.JPanel; |
||
79 | import javax.swing.JSlider; |
||
80 | import javax.swing.JTextField; |
||
81 | import javax.swing.ListCellRenderer; |
||
82 | import javax.swing.UIManager; |
||
83 | import javax.swing.event.ChangeEvent; |
||
84 | import javax.swing.event.ChangeListener; |
||
85 | import javax.swing.plaf.basic.BasicComboBoxEditor; |
||
86 | |||
87 | import com.iver.andami.PluginServices; |
||
88 | import com.iver.cit.gvsig.fmap.core.FPoint2D; |
||
89 | import com.iver.cit.gvsig.fmap.core.FShape; |
||
90 | import com.iver.cit.gvsig.fmap.core.v02.FConstant; |
||
91 | import com.iver.cit.gvsig.fmap.core.v02.FGraphicUtilities; |
||
92 | import com.iver.cit.gvsig.fmap.core.v02.FSymbol; |
||
93 | import com.iver.cit.gvsig.fmap.core.v02.FSymbolFactory; |
||
94 | import com.iver.cit.gvsig.fmap.layers.FLayer; |
||
95 | import com.iver.cit.gvsig.fmap.rendering.Legend; |
||
96 | import com.iver.cit.gvsig.fmap.rendering.SingleSymbolLegend; |
||
97 | import com.iver.cit.gvsig.fmap.rendering.styling.FStyle2D; |
||
98 | import com.iver.cit.gvsig.gui.GUIUtil; |
||
99 | import com.iver.cit.gvsig.gui.Panels.ColorChooserPanel; |
||
100 | import com.iver.cit.gvsig.gui.Panels.TransparencyPanel; |
||
101 | import com.iver.utiles.ImageFilter; |
||
102 | import com.vividsolutions.jump.util.StringUtil; |
||
103 | /**
|
||
104 | * @author fjp
|
||
105 | *
|
||
106 | * To change the template for this generated type comment go to
|
||
107 | * Window>Preferences>Java>Code Generation>Code and Comments
|
||
108 | */
|
||
109 | |||
110 | |||
111 | public class FPanelLegendDefault extends JPanel implements ILegendPanel { |
||
112 | |||
113 | private FSymbol m_FSymbol = null; |
||
114 | |||
115 | |||
116 | protected static final int SLIDER_TEXT_FIELD_COLUMNS = 3; |
||
117 | protected static final Dimension SLIDER_DIMENSION = new Dimension(130, 49); |
||
118 | // private Paint[] fillPatterns = new FillPatternFactory().createFillPatterns();
|
||
119 | private JPanel centerPanel = new JPanel(); |
||
120 | // private AbstractPalettePanel palettePanel;
|
||
121 | protected JCheckBox fillCheckBox = new JCheckBox(); |
||
122 | protected JCheckBox lineCheckBox = new JCheckBox(); |
||
123 | protected TransparencyPanel transparencyPanel = new TransparencyPanel(); |
||
124 | protected JLabel transparencyLabel = new JLabel(); |
||
125 | protected ColorChooserPanel lineColorChooserPanel = new ColorChooserPanel(); |
||
126 | protected ColorChooserPanel fillColorChooserPanel = new ColorChooserPanel(); |
||
127 | protected ColorChooserPanel pointColorChooserPanel = new ColorChooserPanel(); |
||
128 | protected FPreviewSymbol m_previewSymbol = new FPreviewSymbol(); |
||
129 | protected JLabel lineWidthLabel = new JLabel(); |
||
130 | protected JCheckBox synchronizeCheckBox = new JCheckBox(); |
||
131 | private JCheckBox linePatternCheckBox = new JCheckBox(); |
||
132 | private JCheckBox fillPatternCheckBox = new JCheckBox(); |
||
133 | private Paint[] fillPatterns = FSymbolFactory.createPatternFills(Color.GRAY); |
||
134 | private String[] linePatterns = new String[] { |
||
135 | "1", "3", "5", "5,1", "7", "7,12", "9", "9,2", "15,6", "20,3" |
||
136 | }; |
||
137 | |||
138 | private Integer[] pointTypes = new Integer[] { |
||
139 | new Integer(FStyle2D.SYMBOL_STYLE_MARKER_SQUARE), |
||
140 | new Integer(FStyle2D.SYMBOL_STYLE_MARKER_CIRCLE), |
||
141 | new Integer(FStyle2D.SYMBOL_STYLE_MARKER_TRIANGLE), |
||
142 | new Integer(FStyle2D.SYMBOL_STYLE_MARKER_CROSS), |
||
143 | new Integer(FStyle2D.SYMBOL_STYLE_MARKER_IMAGEN) |
||
144 | }; |
||
145 | |||
146 | protected String pointTypeToString(Integer pointType) |
||
147 | { |
||
148 | String resul = "No reconocido"; |
||
149 | switch (pointType.intValue())
|
||
150 | { |
||
151 | case FStyle2D.SYMBOL_STYLE_MARKER_SQUARE:
|
||
152 | resul = "Cuadrado";
|
||
153 | break;
|
||
154 | case FStyle2D.SYMBOL_STYLE_MARKER_CIRCLE:
|
||
155 | resul = "C?rculo";
|
||
156 | break;
|
||
157 | case FStyle2D.SYMBOL_STYLE_MARKER_TRIANGLE:
|
||
158 | resul = "Tri?ngulo";
|
||
159 | break;
|
||
160 | case FStyle2D.SYMBOL_STYLE_MARKER_CROSS:
|
||
161 | resul = "Cruz";
|
||
162 | break;
|
||
163 | case FStyle2D.SYMBOL_STYLE_MARKER_IMAGEN:
|
||
164 | resul = "Imagen";
|
||
165 | break;
|
||
166 | |||
167 | } |
||
168 | return resul;
|
||
169 | } |
||
170 | protected Integer pointTypeToInt(String pointType) |
||
171 | { |
||
172 | if (pointType.compareTo("Cuadrado")== 0) |
||
173 | return new Integer(FStyle2D.SYMBOL_STYLE_MARKER_SQUARE); |
||
174 | if (pointType.compareTo("C?rculo")== 0) |
||
175 | return new Integer(FStyle2D.SYMBOL_STYLE_MARKER_CIRCLE); |
||
176 | if (pointType.compareTo("Tri?ngulo")== 0) |
||
177 | return new Integer(FStyle2D.SYMBOL_STYLE_MARKER_TRIANGLE); |
||
178 | if (pointType.compareTo("Cruz")== 0) |
||
179 | return new Integer(FStyle2D.SYMBOL_STYLE_MARKER_CROSS); |
||
180 | if (pointType.compareTo("Imagen")== 0) |
||
181 | return new Integer(FStyle2D.SYMBOL_STYLE_MARKER_IMAGEN); |
||
182 | return new Integer(-1); |
||
183 | } |
||
184 | private JComboBox pointTypeComboBox = new JComboBox(pointTypes) { |
||
185 | |||
186 | { |
||
187 | 2438 | caballero | BasicComboBoxEditor editor1 = new BasicComboBoxEditor(); |
188 | 1671 | jmorell | |
189 | 2438 | caballero | setEditor(editor1); |
190 | 1671 | jmorell | setEditable(true);
|
191 | addActionListener(new ActionListener() { |
||
192 | public void actionPerformed(ActionEvent e) { |
||
193 | updateControls(false);
|
||
194 | if (getSelectedItem() instanceof Integer) |
||
195 | { |
||
196 | setSelectedItem(pointTypeToString((Integer) getSelectedItem()));
|
||
197 | |||
198 | updateControls(false);
|
||
199 | } |
||
200 | } |
||
201 | }); |
||
202 | setRenderer(new ListCellRenderer() { |
||
203 | private Integer pointType; |
||
204 | private FSymbol myFSymbol = new FSymbol(FConstant.SYMBOL_TYPE_POINT); |
||
205 | private JPanel panel = new JPanel() { |
||
206 | |||
207 | protected void paintComponent(Graphics g) { |
||
208 | super.paintComponent(g);
|
||
209 | |||
210 | Graphics2D g2 = (Graphics2D) g; |
||
211 | AffineTransform mT = new AffineTransform(); |
||
212 | mT.setToIdentity(); |
||
213 | |||
214 | FPoint2D shp = new FPoint2D(panel.getWidth()/2, |
||
215 | panel.getHeight()/2);
|
||
216 | if (m_FSymbol !=null){ |
||
217 | myFSymbol.setColor(m_FSymbol.getColor()); |
||
218 | FGraphicUtilities.DrawShape(g2,mT, shp,myFSymbol); |
||
219 | } |
||
220 | } |
||
221 | }; |
||
222 | |||
223 | |||
224 | public Component getListCellRendererComponent( |
||
225 | JList list, Object value, int index, |
||
226 | boolean isSelected, boolean cellHasFocus) { |
||
227 | pointType = (Integer) value;
|
||
228 | myFSymbol.setStyle(pointType.intValue()); |
||
229 | // Le hacemos que se dibuje siempre con 10 pixels
|
||
230 | |||
231 | myFSymbol.setSizeInPixels(true);
|
||
232 | myFSymbol.setSize(10);
|
||
233 | myFSymbol.setStroke(new BasicStroke()); |
||
234 | panel.setForeground(UIManager.getColor(isSelected
|
||
235 | ? "ComboBox.selectionForeground"
|
||
236 | : "ComboBox.foreground"));
|
||
237 | panel.setBackground(UIManager.getColor(isSelected
|
||
238 | ? "ComboBox.selectionBackground"
|
||
239 | : "ComboBox.background"));
|
||
240 | |||
241 | return panel;
|
||
242 | } |
||
243 | }); |
||
244 | } |
||
245 | }; |
||
246 | |||
247 | /**
|
||
248 | * Converts the comma-delimited string into a List of trimmed strings.
|
||
249 | *
|
||
250 | * @param linePattern a String with comma-delimited values
|
||
251 | * @param lineWidth DOCUMENT ME!
|
||
252 | *
|
||
253 | * @return a List of the Strings that were delimited by commas
|
||
254 | *
|
||
255 | * @throws IllegalArgumentException DOCUMENT ME!
|
||
256 | */
|
||
257 | 2438 | caballero | private float[] toArray(String linePattern, float lineWidth) { |
258 | 1671 | jmorell | List strings = StringUtil.fromCommaDelimitedString(linePattern);
|
259 | float[] array = new float[strings.size()]; |
||
260 | |||
261 | for (int i = 0; i < strings.size(); i++) { |
||
262 | String string = (String) strings.get(i); |
||
263 | array[i] = Float.parseFloat(string) * lineWidth;
|
||
264 | |||
265 | if (array[i] <= 0) { |
||
266 | 2438 | caballero | return null; |
267 | //linePatternCheckBox.setSelected(false);
|
||
268 | //throw new IllegalArgumentException("Negative dash length");
|
||
269 | 1671 | jmorell | } |
270 | } |
||
271 | |||
272 | return array;
|
||
273 | } |
||
274 | |||
275 | protected JSlider lineWidthSlider = new JSlider() { |
||
276 | |||
277 | { |
||
278 | addChangeListener(new ChangeListener() { |
||
279 | public void stateChanged(ChangeEvent e) { |
||
280 | updateControls(false);
|
||
281 | } |
||
282 | }); |
||
283 | } |
||
284 | }; |
||
285 | private JComboBox linePatternComboBox = new JComboBox(linePatterns) { |
||
286 | { |
||
287 | BasicComboBoxEditor editor = new BasicComboBoxEditor(); |
||
288 | setEditor(editor); |
||
289 | setEditable(true);
|
||
290 | addActionListener(new ActionListener() { |
||
291 | public void actionPerformed(ActionEvent e) { |
||
292 | updateControls(false);
|
||
293 | } |
||
294 | }); |
||
295 | setRenderer(new ListCellRenderer() { |
||
296 | private JPanel panel = new JPanel() { |
||
297 | private int lineWidth = 2; |
||
298 | |||
299 | protected void paintComponent(Graphics g) { |
||
300 | super.paintComponent(g);
|
||
301 | |||
302 | Graphics2D g2 = (Graphics2D) g; |
||
303 | g2.setStroke(new BasicStroke(lineWidth, |
||
304 | BasicStroke.CAP_BUTT,
|
||
305 | BasicStroke.JOIN_BEVEL, 1.0f, |
||
306 | toArray(linePattern, lineWidth), 0));
|
||
307 | g2.draw(new Line2D.Double(0, |
||
308 | panel.getHeight() / 2.0,
|
||
309 | panel.getWidth(), |
||
310 | panel.getHeight() / 2.0));
|
||
311 | } |
||
312 | }; |
||
313 | |||
314 | private String linePattern; |
||
315 | |||
316 | public Component getListCellRendererComponent( |
||
317 | JList list, Object value, int index, |
||
318 | boolean isSelected, boolean cellHasFocus) { |
||
319 | linePattern = (String) value;
|
||
320 | panel.setForeground(UIManager.getColor(isSelected
|
||
321 | ? "ComboBox.selectionForeground"
|
||
322 | : "ComboBox.foreground"));
|
||
323 | panel.setBackground(UIManager.getColor(isSelected
|
||
324 | ? "ComboBox.selectionBackground"
|
||
325 | : "ComboBox.background"));
|
||
326 | |||
327 | return panel;
|
||
328 | } |
||
329 | }); |
||
330 | } |
||
331 | }; |
||
332 | |||
333 | 2438 | caballero | private JComboBox fillPatternComboBox=getFillPatternComboBox(); |
334 | private JComboBox getFillPatternComboBox(){ |
||
335 | if (fillPatternComboBox==null){ |
||
336 | fillPatternComboBox =new JComboBox(fillPatterns) { |
||
337 | 1671 | jmorell | |
338 | { |
||
339 | // setMaximumRowCount(fillPatterns.length);
|
||
340 | setEditable(false);
|
||
341 | addActionListener(new ActionListener() { |
||
342 | public void actionPerformed(ActionEvent e) { |
||
343 | updateControls(true);
|
||
344 | } |
||
345 | }); |
||
346 | setRenderer(new ListCellRenderer() { |
||
347 | private Paint fillPattern; |
||
348 | private JLabel label = new JLabel(" "); |
||
349 | private JPanel panel = new JPanel(new BorderLayout()) { |
||
350 | |||
351 | { |
||
352 | label.setPreferredSize(new Dimension(150, |
||
353 | (int) label.getPreferredSize()
|
||
354 | .getHeight())); |
||
355 | add(label, BorderLayout.CENTER);
|
||
356 | } |
||
357 | |||
358 | protected void paintComponent(Graphics g) { |
||
359 | super.paintComponent(g);
|
||
360 | ((Graphics2D) g).setPaint(fillPattern);
|
||
361 | ((Graphics2D) g).fill(new Rectangle2D.Double( |
||
362 | 0, 0, getWidth(), getHeight())); |
||
363 | } |
||
364 | }; |
||
365 | |||
366 | public Component getListCellRendererComponent( |
||
367 | JList list, Object value, int index, |
||
368 | boolean isSelected, boolean cellHasFocus) { |
||
369 | fillPattern = (Paint) value;
|
||
370 | // label.setText("" +(1 +
|
||
371 | // CollectionUtil.indexOf(fillPattern, fillPatterns)));
|
||
372 | label.setForeground(UIManager.getColor(isSelected
|
||
373 | ? "ComboBox.selectionForeground"
|
||
374 | : "ComboBox.foreground"));
|
||
375 | panel.setBackground(UIManager.getColor(isSelected
|
||
376 | ? "ComboBox.selectionBackground"
|
||
377 | : "ComboBox.background"));
|
||
378 | |||
379 | return panel;
|
||
380 | } |
||
381 | }); |
||
382 | } |
||
383 | }; |
||
384 | 2438 | caballero | } |
385 | if (fillPatternCheckBox.isSelected())fillPatternComboBox.setEnabled(true); |
||
386 | return fillPatternComboBox;
|
||
387 | } |
||
388 | //private JComboBox fillPatternComboBox = getFillPatternComboBox();
|
||
389 | 1671 | jmorell | |
390 | |||
391 | private javax.swing.JPanel jPanelPoint = null; // |
||
392 | private javax.swing.JLabel jLabel = null; |
||
393 | private javax.swing.JLabel jLabel1 = null; |
||
394 | private javax.swing.JCheckBox jCheckBox = null; |
||
395 | private javax.swing.JTextField jTextField_Size = null; |
||
396 | private javax.swing.JComboBox jComboBox_Symbol_Type = null; |
||
397 | private javax.swing.JLabel jLabel2 = null; |
||
398 | private JLabel jLblImagen = null; |
||
399 | private JTextField jTxtImagen = null; |
||
400 | private JButton jBtnImagen = null; |
||
401 | /**
|
||
402 | *
|
||
403 | */
|
||
404 | public FPanelLegendDefault() {
|
||
405 | super();
|
||
406 | try {
|
||
407 | jbInit(); |
||
408 | linePatternCheckBox.setSelected(false);
|
||
409 | } catch (Exception e) { |
||
410 | e.printStackTrace(); |
||
411 | } |
||
412 | |||
413 | transparencyPanel.getSlider().getModel().addChangeListener(new ChangeListener() { |
||
414 | public void stateChanged(ChangeEvent e) { |
||
415 | updateControls(true);
|
||
416 | } |
||
417 | }); |
||
418 | /* palettePanel.add(new GridPalettePanel.Listener() {
|
||
419 | public void basicStyleChosen(BasicStyle basicStyle) {
|
||
420 | //Preserve some settings e.g. line and fill patterns, alpha;
|
||
421 | BasicStyle newBasicStyle = getBasicStyle();
|
||
422 | newBasicStyle.setFillColor(basicStyle.getFillColor());
|
||
423 | newBasicStyle.setLineColor(basicStyle.getLineColor());
|
||
424 | newBasicStyle.setLineWidth(basicStyle.getLineWidth());
|
||
425 | newBasicStyle.setRenderingFill(basicStyle.isRenderingFill());
|
||
426 | newBasicStyle.setRenderingLine(basicStyle.isRenderingLine());
|
||
427 | setBasicStyle(newBasicStyle);
|
||
428 | }
|
||
429 | }); */
|
||
430 | updateControls(false);
|
||
431 | |||
432 | } |
||
433 | |||
434 | void jbInit() throws Exception { |
||
435 | java.awt.GridBagConstraints consGridBagConstraints2 = new java.awt.GridBagConstraints();
|
||
436 | |||
437 | lineWidthSlider.setPreferredSize(SLIDER_DIMENSION); |
||
438 | lineWidthSlider.setPaintLabels(true);
|
||
439 | lineWidthSlider.setValue(1);
|
||
440 | lineWidthSlider.setLabelTable(lineWidthSlider.createStandardLabels(10));
|
||
441 | lineWidthSlider.setMajorTickSpacing(5);
|
||
442 | lineWidthSlider.setMaximum(30);
|
||
443 | lineWidthSlider.setMinorTickSpacing(1);
|
||
444 | |||
445 | |||
446 | JPanel globalPanel = new JPanel(); |
||
447 | globalPanel.setLayout(new GridBagLayout()); |
||
448 | |||
449 | linePatternCheckBox.setText(PluginServices.getText(this,"tipo_linea")); |
||
450 | fillPatternCheckBox.setText(PluginServices.getText(this,"tipo_relleno")); |
||
451 | linePatternCheckBox.addActionListener(new java.awt.event.ActionListener() {
|
||
452 | public void actionPerformed(ActionEvent e) { |
||
453 | linePatternCheckBox_actionPerformed(e); |
||
454 | } |
||
455 | }); |
||
456 | fillPatternCheckBox.addActionListener(new java.awt.event.ActionListener() {
|
||
457 | public void actionPerformed(ActionEvent e) { |
||
458 | fillPatternCheckBox_actionPerformed(e); |
||
459 | } |
||
460 | }); |
||
461 | // add(getJPanelPoint());
|
||
462 | globalPanel.add(getCenterPanel(), |
||
463 | new GridBagConstraints(0, 0, 1, 2, 0, 0, GridBagConstraints.WEST, |
||
464 | GridBagConstraints.NONE, new Insets(2, 2, 2, 2), 0, 0)); |
||
465 | |||
466 | /*globalPanel.add(new JPanel(),
|
||
467 | new GridBagConstraints(3, 0, 1, 1, 1, 0, GridBagConstraints.WEST,
|
||
468 | GridBagConstraints.HORIZONTAL, new Insets(2, 2, 2, 2), 0, 0)); */
|
||
469 | /* globalPanel.add(new JLabel("Previsualizaci?n de s?mbolo:"),
|
||
470 | new GridBagConstraints(2, 0, 1, 1, 0, 0, GridBagConstraints.WEST,
|
||
471 | GridBagConstraints.NONE, new Insets(0, 30, 0, 0), 0, 0)); */
|
||
472 | |||
473 | JPanel panelAux = new JPanel(); |
||
474 | panelAux.add(new JLabel(PluginServices.getText(this,"Previsualizacion_de_simbolo"))); |
||
475 | panelAux.add(m_previewSymbol ); |
||
476 | 2204 | vcaballero | panelAux.setVisible(false);
|
477 | 1671 | jmorell | /* globalPanel.add(panelAux, new
|
478 | GridBagConstraints(2, 1, 1, 1, 1, 1, GridBagConstraints.WEST,
|
||
479 | GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); */
|
||
480 | |||
481 | |||
482 | m_previewSymbol.setPreferredSize(new Dimension(80,60)); |
||
483 | m_previewSymbol.setMinimumSize(new Dimension(80,60)); |
||
484 | |||
485 | setLayout(null);
|
||
486 | globalPanel.setBounds(0,0,350,250); |
||
487 | |||
488 | getJPanelPoint().setBounds(0,0,350,250); |
||
489 | add(getJPanelPoint()); //, BorderLayout.WEST); //, consGridBagConstraints2);
|
||
490 | add(globalPanel); // , BorderLayout.WEST);
|
||
491 | |||
492 | panelAux.setBounds(350,0,150,100); |
||
493 | |||
494 | add(panelAux) ; //,BorderLayout.EAST); // Contiene el preview
|
||
495 | |||
496 | /* globalPanel.setBackground(Color.RED);
|
||
497 | getJPanelPoint().setBackground(Color.BLUE);
|
||
498 | panelAux.setBackground(Color.GREEN); */
|
||
499 | |||
500 | getCenterPanel().setLayout(new GridBagLayout()); |
||
501 | setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); |
||
502 | this.setSize(419, 293); |
||
503 | fillColorChooserPanel.addActionListener(new java.awt.event.ActionListener() {
|
||
504 | public void actionPerformed(ActionEvent e) { |
||
505 | fillColorChooserPanel_actionPerformed(e); |
||
506 | } |
||
507 | }); |
||
508 | lineColorChooserPanel.addActionListener(new java.awt.event.ActionListener() {
|
||
509 | public void actionPerformed(ActionEvent e) { |
||
510 | lineColorChooserPanel_actionPerformed(e); |
||
511 | } |
||
512 | }); |
||
513 | |||
514 | synchronizeCheckBox.setText(PluginServices.getText(this,"sincronizar_color_borde_relleno")); |
||
515 | synchronizeCheckBox.addActionListener(new java.awt.event.ActionListener() {
|
||
516 | public void actionPerformed(ActionEvent e) { |
||
517 | synchronizeCheckBox_actionPerformed(e); |
||
518 | } |
||
519 | }); |
||
520 | fillCheckBox.setText(PluginServices.getText(this,"relleno")); |
||
521 | fillCheckBox.addActionListener(new java.awt.event.ActionListener() {
|
||
522 | public void actionPerformed(ActionEvent e) { |
||
523 | fillCheckBox_actionPerformed(e); |
||
524 | } |
||
525 | }); |
||
526 | lineCheckBox.setText(PluginServices.getText(this,"linea")); |
||
527 | lineCheckBox.addActionListener(new java.awt.event.ActionListener() {
|
||
528 | public void actionPerformed(ActionEvent e) { |
||
529 | lineCheckBox_actionPerformed(e); |
||
530 | } |
||
531 | }); |
||
532 | getCenterPanel().add(GUIUtil.createSyncdTextField( |
||
533 | transparencyPanel.getSlider(), SLIDER_TEXT_FIELD_COLUMNS), |
||
534 | new GridBagConstraints(2, 21, 1, 1, 0.0, 0.0, |
||
535 | GridBagConstraints.CENTER, GridBagConstraints.NONE, |
||
536 | new Insets(2, 2, 2, 2), 0, 0)); |
||
537 | getCenterPanel().add(lineWidthSlider, |
||
538 | new GridBagConstraints(1, 19, 1, 1, 0.0, 0.0, |
||
539 | GridBagConstraints.WEST, GridBagConstraints.NONE, |
||
540 | new Insets(2, 2, 2, 2), 0, 0)); |
||
541 | getCenterPanel().add(GUIUtil.createSyncdTextField(lineWidthSlider, |
||
542 | SLIDER_TEXT_FIELD_COLUMNS), |
||
543 | new GridBagConstraints(2, 19, 1, 1, 0.0, 0.0, |
||
544 | GridBagConstraints.WEST, GridBagConstraints.NONE, |
||
545 | new Insets(2, 2, 2, 2), 0, 0)); |
||
546 | fillColorChooserPanel.addActionListener(new java.awt.event.ActionListener() {
|
||
547 | public void actionPerformed(ActionEvent e) { |
||
548 | fillColorChooserPanel_actionPerformed(e); |
||
549 | } |
||
550 | }); |
||
551 | lineWidthLabel.setText(PluginServices.getText(this,"grosor_linea")); |
||
552 | transparencyLabel.setText(PluginServices.getText(this,"transparencia")); |
||
553 | consGridBagConstraints2.gridx = 0;
|
||
554 | consGridBagConstraints2.gridy = 0;
|
||
555 | consGridBagConstraints2.anchor = java.awt.GridBagConstraints.NORTHWEST; |
||
556 | consGridBagConstraints2.fill = java.awt.GridBagConstraints.NONE; |
||
557 | getCenterPanel().add(synchronizeCheckBox, |
||
558 | new GridBagConstraints(0, 18, 3, 1, 0.0, 0.0, |
||
559 | GridBagConstraints.WEST, GridBagConstraints.NONE, |
||
560 | new Insets(2, 2, 2, 2), 0, 0)); |
||
561 | getCenterPanel().add(transparencyLabel, |
||
562 | new GridBagConstraints(0, 21, 1, 1, 0.0, 0.0, |
||
563 | GridBagConstraints.WEST, GridBagConstraints.NONE, |
||
564 | new Insets(2, 2, 2, 2), 0, 0)); |
||
565 | getCenterPanel().add(fillColorChooserPanel, |
||
566 | new GridBagConstraints(1, 5, 2, 1, 0.0, 0.0, |
||
567 | GridBagConstraints.WEST, GridBagConstraints.NONE, |
||
568 | new Insets(2, 2, 2, 2), 0, 0)); |
||
569 | |||
570 | |||
571 | getCenterPanel().add(lineColorChooserPanel, |
||
572 | new GridBagConstraints(1, 11, 2, 1, 0.0, 0.0, |
||
573 | GridBagConstraints.WEST, GridBagConstraints.NONE, |
||
574 | new Insets(2, 2, 2, 2), 0, 0)); |
||
575 | getCenterPanel().add(transparencyPanel, |
||
576 | new GridBagConstraints(1, 21, 1, 1, 0.0, 0.0, |
||
577 | GridBagConstraints.CENTER, GridBagConstraints.NONE, |
||
578 | new Insets(2, 2, 2, 2), 0, 0)); |
||
579 | getCenterPanel().add(fillCheckBox, |
||
580 | new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0, |
||
581 | GridBagConstraints.WEST, GridBagConstraints.NONE, |
||
582 | new Insets(2, 2, 2, 2), 0, 0)); |
||
583 | getCenterPanel().add(lineCheckBox, |
||
584 | new GridBagConstraints(0, 11, 1, 1, 0.0, 0.0, |
||
585 | GridBagConstraints.WEST, GridBagConstraints.NONE, |
||
586 | new Insets(2, 2, 2, 2), 0, 0)); |
||
587 | getCenterPanel().add(lineWidthLabel, |
||
588 | new GridBagConstraints(0, 19, 1, 1, 0.0, 0.0, |
||
589 | GridBagConstraints.WEST, GridBagConstraints.NONE, |
||
590 | new Insets(2, 2, 2, 2), 0, 0)); |
||
591 | getCenterPanel().add(linePatternCheckBox, |
||
592 | new GridBagConstraints(0, 16, 1, 1, 0.0, 0.0, |
||
593 | GridBagConstraints.WEST, GridBagConstraints.NONE, |
||
594 | new Insets(2, 2, 2, 2), 0, 0)); |
||
595 | getCenterPanel().add(fillPatternCheckBox, |
||
596 | new GridBagConstraints(0, 7, 1, 1, 0.0, 0.0, |
||
597 | GridBagConstraints.WEST, GridBagConstraints.NONE, |
||
598 | new Insets(2, 2, 2, 2), 0, 0)); |
||
599 | getCenterPanel().add(linePatternComboBox, |
||
600 | new GridBagConstraints(1, 16, 2, 1, 0.0, 0.0, |
||
601 | GridBagConstraints.WEST, GridBagConstraints.NONE, |
||
602 | new Insets(2, 2, 2, 2), 0, 0)); |
||
603 | 2438 | caballero | getCenterPanel().add(getFillPatternComboBox(), |
604 | 1671 | jmorell | new GridBagConstraints(1, 7, 2, 1, 0.0, 0.0, |
605 | GridBagConstraints.WEST, GridBagConstraints.NONE, |
||
606 | new Insets(2, 2, 0, 2), 0, 0)); |
||
607 | |||
608 | pointTypeComboBox.setBounds(143, 25, 120, 20); |
||
609 | pointColorChooserPanel.addActionListener(new java.awt.event.ActionListener() {
|
||
610 | public void actionPerformed(ActionEvent e) { |
||
611 | updateControls(false);
|
||
612 | } |
||
613 | }); |
||
614 | |||
615 | // this.setSize(348, 243);
|
||
616 | |||
617 | } |
||
618 | |||
619 | protected void setAlpha(int alpha) { |
||
620 | transparencyPanel.getSlider().setValue(255 - alpha);
|
||
621 | } |
||
622 | |||
623 | protected int getAlpha() { |
||
624 | return 255 - transparencyPanel.getSlider().getValue(); |
||
625 | } |
||
626 | |||
627 | void fillCheckBox_actionPerformed(ActionEvent e) { |
||
628 | updateControls(false);
|
||
629 | } |
||
630 | |||
631 | void lineCheckBox_actionPerformed(ActionEvent e) { |
||
632 | updateControls(false);
|
||
633 | } |
||
634 | |||
635 | 2438 | caballero | /*private void setSynchronizingLineColor(boolean newSynchronizingLineColor) {
|
636 | 1671 | jmorell | synchronizeCheckBox.setSelected(newSynchronizingLineColor);
|
637 | }
|
||
638 | 2438 | caballero | */
|
639 | 1671 | jmorell | protected void synchronizeCheckBox_actionPerformed(ActionEvent e) { |
640 | if (synchronizeCheckBox.isSelected()) {
|
||
641 | syncLineColor(); |
||
642 | } |
||
643 | |||
644 | updateControls(false);
|
||
645 | } |
||
646 | 2438 | caballero | /*
|
647 | 1671 | jmorell | private JCheckBox getSynchronizeCheckBox() {
|
648 | return synchronizeCheckBox;
|
||
649 | }
|
||
650 | 2438 | caballero | */
|
651 | 1671 | jmorell | void linePatternCheckBox_actionPerformed(ActionEvent e) { |
652 | updateControls(false);
|
||
653 | } |
||
654 | void lineColorChooserPanel_actionPerformed(ActionEvent e) { |
||
655 | if (synchronizeCheckBox.isSelected()) {
|
||
656 | fillColorChooserPanel.setColor(lineColorChooserPanel.getColor() |
||
657 | .brighter()); |
||
658 | } |
||
659 | |||
660 | updateControls(false);
|
||
661 | } |
||
662 | void fillColorChooserPanel_actionPerformed(ActionEvent e) { |
||
663 | if (synchronizeCheckBox.isSelected()) {
|
||
664 | syncLineColor(); |
||
665 | } |
||
666 | |||
667 | updateControls(true);
|
||
668 | } |
||
669 | private void syncLineColor() { |
||
670 | lineColorChooserPanel.setColor(fillColorChooserPanel.getColor().darker()); |
||
671 | } |
||
672 | |||
673 | void fillPatternCheckBox_actionPerformed(ActionEvent e) { |
||
674 | updateControls(false);
|
||
675 | } |
||
676 | private void updateFillPatternColors() { |
||
677 | if ((m_FSymbol != null) && (m_FSymbol.getColor() != null)) |
||
678 | { |
||
679 | fillPatterns = FSymbolFactory.createPatternFills(m_FSymbol.getColor()); |
||
680 | 2438 | caballero | int index=getFillPatternComboBox().getSelectedIndex();
|
681 | //fillPatternComboBox=getFillPatternComboBox();
|
||
682 | getFillPatternComboBox().setModel(new DefaultComboBoxModel(fillPatterns)); |
||
683 | getFillPatternComboBox().getModel().setSelectedItem(m_FSymbol.getFill()); |
||
684 | getFillPatternComboBox().setSelectedIndex(index); |
||
685 | 1671 | jmorell | } |
686 | |||
687 | } |
||
688 | |||
689 | public void updateControls(boolean bInternal) { |
||
690 | linePatternComboBox.setEnabled(linePatternCheckBox.isSelected()); |
||
691 | 2438 | caballero | getFillPatternComboBox().setEnabled(fillPatternCheckBox.isSelected()); |
692 | 1671 | jmorell | lineColorChooserPanel.setEnabled(lineCheckBox.isSelected()); |
693 | fillColorChooserPanel.setEnabled(fillCheckBox.isSelected()); |
||
694 | fillColorChooserPanel.setAlpha(getAlpha()); |
||
695 | lineColorChooserPanel.setAlpha(getAlpha()); |
||
696 | Color theColor = (lineCheckBox.isSelected() &&
|
||
697 | !fillCheckBox.isSelected()) ? lineColorChooserPanel.getColor() |
||
698 | : fillColorChooserPanel.getColor(); |
||
699 | transparencyPanel.setColor(theColor); |
||
700 | if (jTxtImagen != null) |
||
701 | { |
||
702 | jTxtImagen.setVisible(false);
|
||
703 | jLblImagen.setVisible(false);
|
||
704 | jBtnImagen.setVisible(false);
|
||
705 | } |
||
706 | if (m_FSymbol != null) |
||
707 | { |
||
708 | if (m_FSymbol.getSymbolType() == FConstant.SYMBOL_TYPE_POINT)
|
||
709 | { |
||
710 | m_FSymbol.setSize(Integer.parseInt(getJTextField().getText()));
|
||
711 | |||
712 | //System.out.println("Asigno el m_Size = " + getJTextField().getText());
|
||
713 | |||
714 | if (pointTypeComboBox.getSelectedItem() instanceof Integer) |
||
715 | { |
||
716 | Integer styleSelected = (Integer) pointTypeComboBox.getSelectedItem(); |
||
717 | m_FSymbol.setStyle(styleSelected.intValue()); |
||
718 | } |
||
719 | else
|
||
720 | { |
||
721 | Integer styleSelected = pointTypeToInt((String) pointTypeComboBox.getSelectedItem()); |
||
722 | m_FSymbol.setStyle(styleSelected.intValue()); |
||
723 | } |
||
724 | if (m_FSymbol.getStyle() == FConstant.SYMBOL_STYLE_MARKER_IMAGEN)
|
||
725 | { |
||
726 | jTxtImagen.setVisible(true);
|
||
727 | jLblImagen.setVisible(true);
|
||
728 | jBtnImagen.setVisible(true);
|
||
729 | if (jTxtImagen.getText().compareTo("") != 0) |
||
730 | { |
||
731 | 2452 | fjp | File iconFile = new File(jTxtImagen.getText()); |
732 | URI theUri= iconFile.toURI();
|
||
733 | m_FSymbol.setIconURI(theUri); |
||
734 | 1671 | jmorell | } |
735 | } |
||
736 | m_FSymbol.setColor(pointColorChooserPanel.getColor()); |
||
737 | m_FSymbol.setSizeInPixels(!getJCheckBox().isSelected()); |
||
738 | pointColorChooserPanel.repaint(); |
||
739 | m_previewSymbol.setSymbol(m_FSymbol); |
||
740 | return;
|
||
741 | } |
||
742 | m_FSymbol.setOutlined(lineCheckBox.isSelected()); |
||
743 | m_FSymbol.setOutlineColor(lineColorChooserPanel.getColor()); |
||
744 | if (fillCheckBox.isSelected())
|
||
745 | { |
||
746 | m_FSymbol.setColor(new Color(theColor.getRed(), |
||
747 | theColor.getGreen(), |
||
748 | theColor.getBlue(), |
||
749 | getAlpha())); |
||
750 | } |
||
751 | else
|
||
752 | { |
||
753 | m_FSymbol.setColor(null);
|
||
754 | } |
||
755 | if (fillPatternCheckBox.isSelected())
|
||
756 | { |
||
757 | 2438 | caballero | Paint fillAux = (Paint) getFillPatternComboBox().getSelectedItem(); |
758 | if ((fillAux != null) && (getFillPatternComboBox().getSelectedIndex() != -1)) |
||
759 | 1671 | jmorell | { |
760 | 2438 | caballero | m_FSymbol.setFill((Paint) getFillPatternComboBox().getSelectedItem());
|
761 | 1671 | jmorell | // Rellenamos el m_Style para que luego podamos escribir
|
762 | // el tipo de relleno que lleva.
|
||
763 | 2438 | caballero | m_FSymbol.setStyle(getFillPatternComboBox().getSelectedIndex()+3);
|
764 | 1671 | jmorell | System.out.println("Asigno Style=" + m_FSymbol.getStyle()); |
765 | } |
||
766 | } |
||
767 | else
|
||
768 | if (bInternal == false) |
||
769 | m_FSymbol.setFill(null);
|
||
770 | |||
771 | float lineWidth = lineWidthSlider.getValue();
|
||
772 | if (linePatternCheckBox.isSelected())
|
||
773 | 2438 | caballero | { |
774 | |||
775 | 1671 | jmorell | String linePattern = (String) linePatternComboBox.getSelectedItem(); |
776 | 2438 | caballero | |
777 | 1671 | jmorell | // System.out.println(m_FSymbol.m_Stroke.toString());
|
778 | m_FSymbol.setStroke(new BasicStroke(lineWidth, BasicStroke.CAP_ROUND, |
||
779 | BasicStroke.JOIN_BEVEL, 1.0f, |
||
780 | toArray(linePattern, lineWidth), 0));
|
||
781 | m_FSymbol.m_LinePattern = linePattern; |
||
782 | 2438 | caballero | |
783 | 1671 | jmorell | } |
784 | else
|
||
785 | { |
||
786 | if (lineWidth <=1) |
||
787 | m_FSymbol.setStroke(null);
|
||
788 | else
|
||
789 | m_FSymbol.setStroke(new BasicStroke(lineWidth, BasicStroke.CAP_ROUND, |
||
790 | BasicStroke.JOIN_BEVEL));
|
||
791 | } |
||
792 | // System.out.println(fillPatternComboBox.getSelectedItem().toString() + " " + linePatternComboBox.getSelectedItem().toString());
|
||
793 | // JOptionPane.showMessageDialog(this,"HOla","Colega", JOptionPane.INFORMATION_MESSAGE);
|
||
794 | m_previewSymbol.setSymbol(m_FSymbol); |
||
795 | } |
||
796 | |||
797 | updateFillPatternColors(); |
||
798 | 2438 | caballero | getFillPatternComboBox().repaint(); |
799 | 1671 | jmorell | } |
800 | |||
801 | public void setFSymbol(FSymbol s) |
||
802 | { |
||
803 | if (s==null) |
||
804 | { |
||
805 | m_FSymbol = new FSymbol(FShape.MULTI);
|
||
806 | } |
||
807 | m_FSymbol = s.fastCloneSymbol(); |
||
808 | m_previewSymbol.setSymbol(m_FSymbol); |
||
809 | if ((m_FSymbol.getSymbolType() == FConstant.SYMBOL_TYPE_FILL) || (m_FSymbol.getSymbolType() == FShape.MULTI))
|
||
810 | { |
||
811 | // Deber?amos habilitar la pesta?a de pol?gonos
|
||
812 | getJPanelPoint().setVisible(false);
|
||
813 | getCenterPanel().setVisible(true);
|
||
814 | fillCheckBox.setText(PluginServices.getText(this,"relleno")); |
||
815 | synchronizeCheckBox.setVisible(true);
|
||
816 | fillPatternCheckBox.setVisible(true);
|
||
817 | 2438 | caballero | getFillPatternComboBox().setVisible(true);
|
818 | 1671 | jmorell | lineCheckBox.setVisible(true);
|
819 | lineColorChooserPanel.setVisible(true);
|
||
820 | |||
821 | lineCheckBox.setSelected(m_FSymbol.isOutlined()); |
||
822 | lineColorChooserPanel.setColor(m_FSymbol.getOutlineColor()); |
||
823 | if (m_FSymbol.getColor() != null) |
||
824 | { |
||
825 | fillCheckBox.setSelected(true);
|
||
826 | fillColorChooserPanel.setColor(m_FSymbol.getColor()); |
||
827 | setAlpha(m_FSymbol.getColor().getAlpha()); |
||
828 | fillColorChooserPanel.setAlpha(getAlpha()); |
||
829 | lineColorChooserPanel.setAlpha(getAlpha()); |
||
830 | } |
||
831 | else
|
||
832 | { |
||
833 | fillCheckBox.setSelected(false);
|
||
834 | } |
||
835 | |||
836 | linePatternCheckBox.setSelected(false);
|
||
837 | if (m_FSymbol.getStroke() != null) |
||
838 | { |
||
839 | BasicStroke aux = (BasicStroke) m_FSymbol.getStroke(); |
||
840 | if (aux.getDashArray() != null) |
||
841 | { |
||
842 | linePatternCheckBox.setSelected(true);
|
||
843 | linePatternComboBox.setSelectedItem(m_FSymbol.m_LinePattern); |
||
844 | } |
||
845 | } |
||
846 | if (m_FSymbol.getFill() != null) |
||
847 | { |
||
848 | fillPatternCheckBox.setSelected(true);
|
||
849 | 2438 | caballero | getFillPatternComboBox().setSelectedItem(new Integer(m_FSymbol.getStyle())); |
850 | 1671 | jmorell | } |
851 | |||
852 | } |
||
853 | if (m_FSymbol.getSymbolType() == FConstant.SYMBOL_TYPE_LINE)
|
||
854 | { |
||
855 | getJPanelPoint().setVisible(false);
|
||
856 | getCenterPanel().setVisible(true);
|
||
857 | fillCheckBox.setText(PluginServices.getText(this,"linea")); // Lo vamos a usar como color de l?nea |
||
858 | fillCheckBox.setSelected(true);
|
||
859 | synchronizeCheckBox.setVisible(false);
|
||
860 | fillPatternCheckBox.setVisible(false);
|
||
861 | 2438 | caballero | getFillPatternComboBox().setVisible(false);
|
862 | 1671 | jmorell | lineCheckBox.setSelected(true);
|
863 | lineCheckBox.setVisible(false);
|
||
864 | fillColorChooserPanel.setColor(m_FSymbol.getColor()); |
||
865 | lineColorChooserPanel.setVisible(false);
|
||
866 | if (m_FSymbol.getColor() != null) |
||
867 | { |
||
868 | lineColorChooserPanel.setColor(m_FSymbol.getColor()); |
||
869 | setAlpha(m_FSymbol.getColor().getAlpha()); |
||
870 | lineColorChooserPanel.setAlpha(getAlpha()); |
||
871 | } |
||
872 | linePatternCheckBox.setSelected(false);
|
||
873 | if (m_FSymbol.getStroke() != null) |
||
874 | { |
||
875 | BasicStroke aux = (BasicStroke) m_FSymbol.getStroke(); |
||
876 | if (aux.getDashArray() != null) |
||
877 | { |
||
878 | linePatternCheckBox.setSelected(true);
|
||
879 | linePatternComboBox.setSelectedItem(m_FSymbol.m_LinePattern); |
||
880 | } |
||
881 | } |
||
882 | } |
||
883 | if (m_FSymbol.getSymbolType() == FConstant.SYMBOL_TYPE_POINT)
|
||
884 | { |
||
885 | getCenterPanel().setVisible(false);
|
||
886 | getJPanelPoint().setVisible(true);
|
||
887 | if (m_FSymbol.getColor()!=null){ |
||
888 | pointColorChooserPanel.setColor(m_FSymbol.getColor()); |
||
889 | } |
||
890 | getJTextField().setText("" + m_FSymbol.getSize());
|
||
891 | getJCheckBox().setSelected(!m_FSymbol.isSizeInPixels()); |
||
892 | getJComboBox_pointType().setSelectedItem(new Integer(m_FSymbol.getStyle())); |
||
893 | |||
894 | 2452 | fjp | if (m_FSymbol.getStyle() == FConstant.SYMBOL_STYLE_MARKER_IMAGEN)
|
895 | { |
||
896 | File fProv = new File(m_FSymbol.getIconURI()); |
||
897 | jTxtImagen.setText(fProv.getAbsolutePath()); |
||
898 | jTxtImagen.setVisible(true);
|
||
899 | jLblImagen.setVisible(true);
|
||
900 | jBtnImagen.setVisible(true);
|
||
901 | } |
||
902 | |||
903 | 1671 | jmorell | } |
904 | |||
905 | // setAlpha(255 - m_FSymbol.m_Transparency);
|
||
906 | |||
907 | } |
||
908 | |||
909 | /**
|
||
910 | * @return
|
||
911 | */
|
||
912 | public FSymbol getFSymbol() {
|
||
913 | updateControls(false);
|
||
914 | return m_FSymbol;
|
||
915 | } |
||
916 | |||
917 | protected void setCenterPanel(JPanel centerPanel) { |
||
918 | this.centerPanel = centerPanel;
|
||
919 | } |
||
920 | |||
921 | protected JPanel getCenterPanel() { |
||
922 | return centerPanel;
|
||
923 | } |
||
924 | |||
925 | /**
|
||
926 | |||
927 | * This method initializes jPanel
|
||
928 | |||
929 | *
|
||
930 | |||
931 | * @return javax.swing.JPanel
|
||
932 | |||
933 | */
|
||
934 | protected javax.swing.JPanel getJPanelPoint() {
|
||
935 | if (jPanelPoint == null) { |
||
936 | jLblImagen = new JLabel(); |
||
937 | jPanelPoint = new javax.swing.JPanel();
|
||
938 | jPanelPoint.setLayout(null);
|
||
939 | jPanelPoint.setPreferredSize(new Dimension(300,200)); |
||
940 | jPanelPoint.setBounds(0, 2, 336, 217); |
||
941 | jLblImagen.setBounds(25, 139, 71, 18); |
||
942 | jLblImagen.setText(PluginServices.getText(this,"imagen")); |
||
943 | jPanelPoint.add(getJLabel2(), null);
|
||
944 | jPanelPoint.add(getJLabel(), null);
|
||
945 | jPanelPoint.add(getJLabel1(), null);
|
||
946 | jPanelPoint.add(getJCheckBox(), null);
|
||
947 | jPanelPoint.add(getJTextField(), null);
|
||
948 | jPanelPoint.add(getJComboBox_pointType(), null);
|
||
949 | pointColorChooserPanel.setBounds(143, 54, 98, 22); |
||
950 | pointColorChooserPanel.setAlpha(255);
|
||
951 | jPanelPoint.add(pointColorChooserPanel); |
||
952 | jPanelPoint.add(jLblImagen, null);
|
||
953 | jPanelPoint.add(getJTextField2(), null);
|
||
954 | jPanelPoint.add(getJBtnImagen(), null);
|
||
955 | } |
||
956 | return jPanelPoint;
|
||
957 | } |
||
958 | |||
959 | /**
|
||
960 | |||
961 | * This method initializes jLabel
|
||
962 | |||
963 | *
|
||
964 | |||
965 | * @return javax.swing.JLabel
|
||
966 | |||
967 | */
|
||
968 | private javax.swing.JLabel getJLabel() {
|
||
969 | if (jLabel == null) { |
||
970 | jLabel = new javax.swing.JLabel();
|
||
971 | jLabel.setText(PluginServices.getText(this,"tipo_simbolo")); |
||
972 | jLabel.setBounds(25, 23, 113, 22); |
||
973 | } |
||
974 | return jLabel;
|
||
975 | } |
||
976 | |||
977 | /**
|
||
978 | |||
979 | * This method initializes jLabel1
|
||
980 | |||
981 | *
|
||
982 | |||
983 | * @return javax.swing.JLabel
|
||
984 | |||
985 | */
|
||
986 | private javax.swing.JLabel getJLabel1() {
|
||
987 | if (jLabel1 == null) { |
||
988 | jLabel1 = new javax.swing.JLabel();
|
||
989 | jLabel1.setBounds(25, 84, 77, 22); |
||
990 | jLabel1.setText(PluginServices.getText(this,"tamano")); |
||
991 | } |
||
992 | return jLabel1;
|
||
993 | } |
||
994 | |||
995 | /**
|
||
996 | |||
997 | * This method initializes jCheckBox
|
||
998 | |||
999 | *
|
||
1000 | |||
1001 | * @return javax.swing.JCheckBox
|
||
1002 | |||
1003 | */
|
||
1004 | private javax.swing.JCheckBox getJCheckBox() {
|
||
1005 | if (jCheckBox == null) { |
||
1006 | jCheckBox = new javax.swing.JCheckBox();
|
||
1007 | jCheckBox.setBounds(143, 115, 145, 19); |
||
1008 | jCheckBox.setText(PluginServices.getText(this,"tamano_metros")); |
||
1009 | } |
||
1010 | return jCheckBox;
|
||
1011 | } |
||
1012 | |||
1013 | /**
|
||
1014 | |||
1015 | * This method initializes jTextField
|
||
1016 | |||
1017 | *
|
||
1018 | |||
1019 | * @return javax.swing.JTextField
|
||
1020 | |||
1021 | */
|
||
1022 | private javax.swing.JTextField getJTextField() {
|
||
1023 | if (jTextField_Size == null) { |
||
1024 | jTextField_Size = new javax.swing.JTextField();
|
||
1025 | jTextField_Size.setBounds(143, 86, 76, 20); |
||
1026 | jTextField_Size.setText("12");
|
||
1027 | jTextField_Size.addActionListener(new java.awt.event.ActionListener() {
|
||
1028 | public void actionPerformed(ActionEvent arg0) { |
||
1029 | updateControls(false);
|
||
1030 | } |
||
1031 | }); |
||
1032 | } |
||
1033 | return jTextField_Size;
|
||
1034 | } |
||
1035 | |||
1036 | /**
|
||
1037 | |||
1038 | * This method initializes jComboBox
|
||
1039 | |||
1040 | *
|
||
1041 | |||
1042 | * @return javax.swing.JComboBox
|
||
1043 | |||
1044 | */
|
||
1045 | private javax.swing.JComboBox getJComboBox_pointType() {
|
||
1046 | if (jComboBox_Symbol_Type == null) { |
||
1047 | jComboBox_Symbol_Type = new javax.swing.JComboBox();
|
||
1048 | jComboBox_Symbol_Type.setBounds(143, 25, 120, 20); |
||
1049 | } |
||
1050 | // return jComboBox_Symbol_Type;
|
||
1051 | return pointTypeComboBox;
|
||
1052 | } |
||
1053 | |||
1054 | /**
|
||
1055 | |||
1056 | * This method initializes jLabel2
|
||
1057 | |||
1058 | *
|
||
1059 | |||
1060 | * @return javax.swing.JLabel
|
||
1061 | |||
1062 | */
|
||
1063 | private javax.swing.JLabel getJLabel2() {
|
||
1064 | if (jLabel2 == null) { |
||
1065 | jLabel2 = new javax.swing.JLabel();
|
||
1066 | jLabel2.setBounds(25, 54, 68, 22); |
||
1067 | jLabel2.setText(PluginServices.getText(this,"color")); |
||
1068 | } |
||
1069 | return jLabel2;
|
||
1070 | } |
||
1071 | |||
1072 | /**
|
||
1073 | * This method initializes jTextField
|
||
1074 | *
|
||
1075 | * @return javax.swing.JTextField
|
||
1076 | */
|
||
1077 | private JTextField getJTextField2() { |
||
1078 | if (jTxtImagen == null) { |
||
1079 | jTxtImagen = new JTextField(); |
||
1080 | jTxtImagen.setBounds(103, 139, 168, 18); |
||
1081 | } |
||
1082 | return jTxtImagen;
|
||
1083 | } |
||
1084 | /**
|
||
1085 | * This method initializes jButton
|
||
1086 | *
|
||
1087 | * @return javax.swing.JButton
|
||
1088 | */
|
||
1089 | private JButton getJBtnImagen() { |
||
1090 | if (jBtnImagen == null) { |
||
1091 | jBtnImagen = new JButton(); |
||
1092 | jBtnImagen.setBounds(279, 139, 33, 18); |
||
1093 | jBtnImagen.setText("...");
|
||
1094 | jBtnImagen.setToolTipText(PluginServices.getText(this,"browse")); |
||
1095 | jBtnImagen.addActionListener(new java.awt.event.ActionListener() {
|
||
1096 | public void actionPerformed(java.awt.event.ActionEvent e) { |
||
1097 | JFileChooser tempChooser = new JFileChooser(); |
||
1098 | ImageFilter filter = new ImageFilter(); |
||
1099 | tempChooser.setFileFilter(filter); |
||
1100 | |||
1101 | int result = tempChooser.showOpenDialog((Component) e.getSource()); |
||
1102 | tempChooser.setMultiSelectionEnabled(false);
|
||
1103 | if (result == JFileChooser.APPROVE_OPTION) { |
||
1104 | File newFile = tempChooser.getSelectedFile();
|
||
1105 | jTxtImagen.setText(newFile.getAbsolutePath()); |
||
1106 | } |
||
1107 | } |
||
1108 | }); |
||
1109 | } |
||
1110 | return jBtnImagen;
|
||
1111 | } |
||
1112 | /* (non-Javadoc)
|
||
1113 | * @see com.iver.cit.gvsig.gui.legendmanager.panels.ILegendPanel#setLayer(com.iver.cit.gvsig.fmap.layers.FLayer, com.iver.cit.gvsig.fmap.rendering.Legend)
|
||
1114 | */
|
||
1115 | public void setLayer(FLayer lyr, Legend legend) { |
||
1116 | 2438 | caballero | //FSymbol aux;
|
1117 | //if (legend.getDefaultSymbol() == null)
|
||
1118 | // aux = new FSymbol(((VectorialLegend)legend).getShapeType());
|
||
1119 | //else
|
||
1120 | 1671 | jmorell | |
1121 | setFSymbol(legend.getDefaultSymbol()); |
||
1122 | |||
1123 | } |
||
1124 | /* (non-Javadoc)
|
||
1125 | * @see com.iver.cit.gvsig.gui.legendmanager.panels.ILegendPanel#getLegend()
|
||
1126 | */
|
||
1127 | public Legend getLegend() {
|
||
1128 | return new SingleSymbolLegend(getFSymbol()); |
||
1129 | } |
||
1130 | /**
|
||
1131 | * @return Returns the m_previewSymbol.
|
||
1132 | */
|
||
1133 | public FPreviewSymbol getM_previewSymbol() {
|
||
1134 | return m_previewSymbol;
|
||
1135 | } |
||
1136 | } // @jve:visual-info decl-index=0 visual-constraint="10,10" |