root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / view / legend / gui / AbstractPanel.java @ 7304
History | View | Annotate | Download (1.84 KB)
1 |
package com.iver.cit.gvsig.project.documents.view.legend.gui; |
---|---|
2 |
|
3 |
import com.iver.andami.PluginServices; |
4 |
import com.iver.andami.messages.Messages; |
5 |
|
6 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
7 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
8 |
import com.iver.cit.gvsig.fmap.layers.layerOperations.Classifiable; |
9 |
import com.iver.cit.gvsig.fmap.rendering.Legend; |
10 |
import com.iver.cit.gvsig.fmap.rendering.VectorialLegend; |
11 |
|
12 |
import javax.swing.JOptionPane; |
13 |
import javax.swing.JPanel; |
14 |
|
15 |
|
16 |
/**
|
17 |
* Clase utilizada para reutilizar m?todos.
|
18 |
*
|
19 |
* @author Vicente Caballero Navarro
|
20 |
*/
|
21 |
public abstract class AbstractPanel extends JPanel { |
22 |
/**
|
23 |
* Cuando hay varios capas vectoriales seleccionados, devolver? el ?ltimo.
|
24 |
*
|
25 |
* @param layers Grupo de layers.
|
26 |
*
|
27 |
* @return la primera flayer seleccionada.
|
28 |
*/
|
29 |
protected FLayer getFirstActiveLayerVect(FLayers layers) {
|
30 |
// Comprobar en openLegendManager que hay alg?n capa activo!
|
31 |
FLayer[] activeLyrs = layers.getActives();
|
32 |
|
33 |
if (activeLyrs.length == 0) { |
34 |
JOptionPane.showMessageDialog(null, |
35 |
Messages.getString("necesita_una_capa_activa"), "", |
36 |
JOptionPane.ERROR_MESSAGE);
|
37 |
|
38 |
return null; |
39 |
} |
40 |
|
41 |
FLayer lyr = null;
|
42 |
|
43 |
for (int i = 0; i < activeLyrs.length; i++) { |
44 |
if (activeLyrs[i] instanceof FLayers) { |
45 |
lyr = getFirstActiveLayerVect((FLayers) activeLyrs[i]); |
46 |
} |
47 |
|
48 |
if (activeLyrs[i] instanceof Classifiable) { |
49 |
Classifiable auxC = (Classifiable) activeLyrs[i]; |
50 |
Legend theLegend = auxC.getLegend(); |
51 |
|
52 |
if (theLegend instanceof VectorialLegend) { |
53 |
lyr = (FLayer) auxC; |
54 |
} |
55 |
} |
56 |
} |
57 |
|
58 |
if (lyr == null) { |
59 |
System.out.println(PluginServices.getText(this, |
60 |
"Por_favor_active_la_capa") + "."); |
61 |
JOptionPane.showMessageDialog(null, |
62 |
Messages.getString(PluginServices.getText(this,
|
63 |
"necesita_una_capa_vectorial_activa")), "", |
64 |
JOptionPane.ERROR_MESSAGE);
|
65 |
|
66 |
return null; |
67 |
} |
68 |
|
69 |
return lyr;
|
70 |
} |
71 |
} |