root / org.gvsig.legend.urbanhorizontalsignage / trunk / org.gvsig.legend.urbanhorizontalsignage / org.gvsig.legend.urbanhorizontalsignage.swing / org.gvsig.legend.urbanhorizontalsignage.swing.impl / src / main / java / org / gvsig / legend / urbanhorizontalsignage / swing / impl / DefaultUrbanHorizontalSignageLegendEditor.java @ 5139
History | View | Annotate | Download (4.74 KB)
1 |
|
---|---|
2 |
package org.gvsig.legend.urbanhorizontalsignage.swing.impl; |
3 |
|
4 |
import java.awt.BorderLayout; |
5 |
import javax.swing.ImageIcon; |
6 |
import javax.swing.JPanel; |
7 |
import org.gvsig.app.project.documents.view.legend.gui.Features; |
8 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
9 |
import org.gvsig.fmap.dal.feature.FeatureType; |
10 |
import org.gvsig.fmap.geom.Geometry; |
11 |
import org.gvsig.fmap.geom.GeometryUtils; |
12 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
13 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
14 |
import org.gvsig.fmap.mapcontext.rendering.legend.ILegend; |
15 |
import org.gvsig.legend.urbanhorizontalsignage.lib.api.UrbanHorizontalSignageLegend; |
16 |
import org.gvsig.legend.urbanhorizontalsignage.lib.api.UrbanHorizontalSignageLocator; |
17 |
import org.gvsig.legend.urbanhorizontalsignage.swing.api.UrbanHorizontalSignageLegendEditor; |
18 |
import org.gvsig.tools.ToolsLocator; |
19 |
import org.gvsig.tools.i18n.I18nManager; |
20 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
21 |
import org.gvsig.tools.swing.api.ToolsSwingManager; |
22 |
import org.gvsig.tools.swing.icontheme.IconTheme; |
23 |
import org.slf4j.Logger; |
24 |
import org.slf4j.LoggerFactory; |
25 |
|
26 |
|
27 |
public class DefaultUrbanHorizontalSignageLegendEditor extends DefaultUrbanHorizontalSignageLegendEditorView implements UrbanHorizontalSignageLegendEditor { |
28 |
|
29 |
private static final long serialVersionUID = 4307714097793669675L; |
30 |
private static final Logger LOGGER = LoggerFactory.getLogger(DefaultUrbanHorizontalSignageLegendEditor.class); |
31 |
|
32 |
private UrbanHorizontalSignageLegend legend;
|
33 |
private FLayer layer;
|
34 |
private final Class<? extends UrbanHorizontalSignageLegend> legendClass; |
35 |
private DefaultUrbanHorizontalSignageConfigPanel configPanel;
|
36 |
|
37 |
public DefaultUrbanHorizontalSignageLegendEditor() {
|
38 |
this.legendClass = UrbanHorizontalSignageLocator.getUrbanHorizontalSignageManager().getLegendClass();
|
39 |
initComponents(); |
40 |
} |
41 |
|
42 |
private void initComponents(){ |
43 |
ToolsSwingManager toolsSwingManager = ToolsSwingLocator.getToolsSwingManager(); |
44 |
|
45 |
configPanel = new DefaultUrbanHorizontalSignageConfigPanel();
|
46 |
this.grdConfig.setLayout(new BorderLayout()); |
47 |
this.grdConfig.add(configPanel,BorderLayout.CENTER); |
48 |
|
49 |
translateAll(); |
50 |
} |
51 |
|
52 |
private void translateAll() { |
53 |
} |
54 |
|
55 |
@Override
|
56 |
public void setData(FLayer layer, ILegend legend) { |
57 |
if( layer == this.layer && legend == this.legend ) { |
58 |
return;
|
59 |
} |
60 |
this.layer = layer;
|
61 |
if( this.getLegendClass().isInstance(legend) ) { |
62 |
this.legend = (UrbanHorizontalSignageLegend) legend;
|
63 |
} else {
|
64 |
this.legend = UrbanHorizontalSignageLocator.getUrbanHorizontalSignageManager().create();
|
65 |
} |
66 |
|
67 |
if( layer instanceof FLyrVect ) { |
68 |
FeatureStore store = ((FLyrVect) layer).getFeatureStore(); |
69 |
if( store != null ) { |
70 |
try {
|
71 |
FeatureType ftype = store.getDefaultFeatureType(); |
72 |
this.configPanel.setFeatureType(ftype);
|
73 |
this.configPanel.put(this.legend.getConfig()); |
74 |
} catch (Exception ex) { |
75 |
LOGGER.warn("Can't fill data of legend.", ex);
|
76 |
//FIXME: ?hacemos algo m?s con la excepci?n?
|
77 |
} |
78 |
} |
79 |
} |
80 |
} |
81 |
|
82 |
@Override
|
83 |
public ILegend getLegend() {
|
84 |
this.configPanel.fetch(this.legend.getConfig()); |
85 |
return legend;
|
86 |
} |
87 |
|
88 |
@Override
|
89 |
public String getDescription() { |
90 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
91 |
return i18n.getTranslation( "_Urban_horizontal_signage_legend_description"); |
92 |
} |
93 |
|
94 |
@Override
|
95 |
public ImageIcon getIcon() { |
96 |
IconTheme theme = ToolsSwingLocator.getIconThemeManager().getCurrent(); |
97 |
return theme.get("legend-overview-vectorial-urbanhorizontalsignage"); |
98 |
} |
99 |
|
100 |
@Override
|
101 |
public Class getParentClass() { |
102 |
return Features.class;
|
103 |
} |
104 |
|
105 |
@Override
|
106 |
public String getTitle() { |
107 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
108 |
return i18n.getTranslation( "_Urban_horizontal_signage_legend"); |
109 |
} |
110 |
|
111 |
@Override
|
112 |
public JPanel getPanel() { |
113 |
return this; |
114 |
} |
115 |
|
116 |
@Override
|
117 |
public Class getLegendClass() { |
118 |
return this.legendClass; |
119 |
} |
120 |
|
121 |
@Override
|
122 |
public boolean isSuitableFor(FLayer layer) { |
123 |
if(layer instanceof FLyrVect){ |
124 |
try {
|
125 |
int shapeType = ((FLyrVect)layer).getShapeType();
|
126 |
return (GeometryUtils.isSubtype(Geometry.TYPES.CURVE, shapeType) ||
|
127 |
GeometryUtils.isSubtype(Geometry.TYPES.MULTICURVE, shapeType)); |
128 |
} catch (Exception ex) { |
129 |
LOGGER.debug("Can't get shape type for layer "+layer.getName(), ex);
|
130 |
return false; |
131 |
} |
132 |
} |
133 |
return false; |
134 |
} |
135 |
|
136 |
} |