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