root / org.gvsig.legend.urbanhorizontalsignage / trunk / org.gvsig.legend.urbanhorizontalsignage / org.gvsig.legend.urbanhorizontalsignage.lib / org.gvsig.legend.urbanhorizontalsignage.lib.impl / src / main / java / org / gvsig / legend / urbanhorizontalsignage / lib / impl / DefaultUrbanHorizontalSignageLegend.java @ 5139
History | View | Annotate | Download (4.3 KB)
1 |
package org.gvsig.legend.urbanhorizontalsignage.lib.impl; |
---|---|
2 |
|
3 |
import java.awt.Image; |
4 |
import org.gvsig.fmap.dal.exception.DataException; |
5 |
import org.gvsig.fmap.dal.feature.Feature; |
6 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
7 |
import org.gvsig.fmap.geom.Geometry; |
8 |
import org.gvsig.fmap.geom.GeometryUtils; |
9 |
import org.gvsig.fmap.mapcontext.MapContextException; |
10 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
11 |
import org.gvsig.legend.urbanhorizontalsignage.lib.api.UrbanHorizontalSignageConfig; |
12 |
import org.gvsig.legend.urbanhorizontalsignage.lib.api.UrbanHorizontalSignageData; |
13 |
import org.gvsig.legend.urbanhorizontalsignage.lib.api.UrbanHorizontalSignageLegend; |
14 |
import org.gvsig.symbology.SymbologyLocator; |
15 |
import org.gvsig.symbology.SymbologyManager; |
16 |
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.impl.AbstractVectorialLegend; |
17 |
import org.gvsig.tools.persistence.PersistentState; |
18 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
19 |
import org.slf4j.Logger; |
20 |
import org.slf4j.LoggerFactory; |
21 |
|
22 |
public class DefaultUrbanHorizontalSignageLegend |
23 |
extends AbstractVectorialLegend
|
24 |
implements UrbanHorizontalSignageLegend //, IHasImageLegend |
25 |
{ |
26 |
|
27 |
private static final Logger LOGGER = LoggerFactory.getLogger(DefaultUrbanHorizontalSignageLegend.class); |
28 |
|
29 |
private UrbanHorizontalSignageSymbol defaultSymbol;
|
30 |
|
31 |
private UrbanHorizontalSignageConfig config;
|
32 |
|
33 |
private Image imageLegend; |
34 |
|
35 |
public DefaultUrbanHorizontalSignageLegend() {
|
36 |
|
37 |
SymbologyManager symbologyManager = SymbologyLocator.getSymbologyManager(); |
38 |
this.defaultSymbol = new UrbanHorizontalSignageSymbol(); |
39 |
DefaultUrbanHorizontalSignageData data = new DefaultUrbanHorizontalSignageData();
|
40 |
data.setContinuity(UrbanHorizontalSignageData.CONTINUITY_MODE_DISC_CONT); |
41 |
this.defaultSymbol.setData(new DefaultUrbanHorizontalSignageData()); |
42 |
|
43 |
this.config = new DefaultUrbanHorizontalSignageConfig(); |
44 |
} |
45 |
|
46 |
@Override
|
47 |
public ISymbol getDefaultSymbol() {
|
48 |
return this.defaultSymbol; |
49 |
} |
50 |
|
51 |
@Override
|
52 |
public void setDefaultSymbol(ISymbol is) { |
53 |
//DO NOTHING
|
54 |
} |
55 |
|
56 |
@Override
|
57 |
public ISymbol getSymbolByFeature(Feature ftr) throws MapContextException { |
58 |
|
59 |
UrbanHorizontalSignageData values = this.getConfig().getValues(ftr);
|
60 |
|
61 |
UrbanHorizontalSignageSymbol symbol = new UrbanHorizontalSignageSymbol();
|
62 |
symbol.setData(values); |
63 |
return symbol;
|
64 |
} |
65 |
|
66 |
@Override
|
67 |
public int getShapeType() { |
68 |
return Geometry.TYPES.CURVE;
|
69 |
} |
70 |
|
71 |
@Override
|
72 |
public void setShapeType(int i) { |
73 |
} |
74 |
|
75 |
@Override
|
76 |
public boolean isUseDefaultSymbol() { |
77 |
return true; |
78 |
} |
79 |
|
80 |
@Override
|
81 |
public void useDefaultSymbol(boolean bln) { |
82 |
} |
83 |
|
84 |
@Override
|
85 |
public boolean isSuitableForShapeType(int shapeType) { |
86 |
return (GeometryUtils.isSubtype(Geometry.TYPES.CURVE, shapeType) ||
|
87 |
GeometryUtils.isSubtype(Geometry.TYPES.MULTICURVE, shapeType)); |
88 |
} |
89 |
|
90 |
@Override
|
91 |
public void loadFromState(PersistentState state) throws PersistenceException { |
92 |
// this.defaultSymbol = new SimpleTextSymbol();
|
93 |
this.imageLegend = null; |
94 |
|
95 |
super.loadFromState(state);
|
96 |
this.config = (UrbanHorizontalSignageConfig) state.get("config"); |
97 |
if(this.config == null){ |
98 |
this.config = new DefaultUrbanHorizontalSignageConfig(); |
99 |
} |
100 |
} |
101 |
|
102 |
@Override
|
103 |
public void saveToState(PersistentState state) throws PersistenceException { |
104 |
super.saveToState(state);
|
105 |
state.set("config", this.getConfig()); |
106 |
} |
107 |
|
108 |
@Override
|
109 |
protected String[] getRequiredFeatureAttributeNames(FeatureStore fs) throws DataException { |
110 |
return new String[]{ |
111 |
this.getConfig().getWidthFieldName(),
|
112 |
this.getConfig().getContinuityFieldName(),
|
113 |
this.getConfig().getHolesLengthFieldName(),
|
114 |
this.getConfig().getHolesColorFieldName(),
|
115 |
this.getConfig().getPaintHolesFieldName(),
|
116 |
this.getConfig().getSegmentsLengthFieldName(),
|
117 |
this.getConfig().getSegmentsColorFieldName(),
|
118 |
this.getConfig().getRoundVertexFieldName(),
|
119 |
fs.getDefaultFeatureType().getDefaultGeometryAttributeName()}; |
120 |
} |
121 |
|
122 |
@Override
|
123 |
public UrbanHorizontalSignageConfig getConfig() {
|
124 |
return config;
|
125 |
} |
126 |
|
127 |
} |