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