root / branches / v2_0_0_prep / libraries / libFMap_dataFile / src / org / gvsig / fmap / data / feature / file / dxf / operation / DXFLegendLabelingManager.java @ 23303
History | View | Annotate | Download (2.68 KB)
1 |
package org.gvsig.fmap.data.feature.file.dxf.operation; |
---|---|
2 |
|
3 |
import java.awt.Color; |
4 |
import java.util.ArrayList; |
5 |
import java.util.Map; |
6 |
import java.util.logging.Logger; |
7 |
|
8 |
import org.cresques.px.dxf.AcadColor; |
9 |
import org.gvsig.fmap.data.DataException; |
10 |
import org.gvsig.fmap.data.feature.Feature; |
11 |
import org.gvsig.fmap.data.feature.FeatureAttributeDescriptor; |
12 |
import org.gvsig.fmap.data.feature.file.dxf.DXFResource; |
13 |
import org.gvsig.fmap.data.feature.operation.LegendLabelingManager; |
14 |
import org.gvsig.fmap.geom.Geometry; |
15 |
import org.gvsig.fmap.mapcontext.rendering.legend.LegendFactory; |
16 |
import org.gvsig.fmap.mapcontext.rendering.legend.VectorialUniqueValueLegend; |
17 |
import org.gvsig.fmap.mapcontext.rendering.legend.styling.AttrInTableLabelingStrategy; |
18 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
19 |
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbologyFactory; |
20 |
|
21 |
public class DXFLegendLabelingManager implements LegendLabelingManager { |
22 |
private AttrInTableLabelingStrategy labeling;
|
23 |
private VectorialUniqueValueLegend defaultLegend;
|
24 |
private ArrayList colors; |
25 |
|
26 |
protected DXFLegendLabelingManager(){
|
27 |
// Legend
|
28 |
defaultLegend = LegendFactory.createVectorialUniqueValueLegend(Geometry.TYPES.GEOMETRY); |
29 |
defaultLegend.setClassifyingFieldNames(new String[] {"Color"}); |
30 |
|
31 |
Logger.getAnonymousLogger().info(
|
32 |
"DXFStore: should check if this is a text symbol");
|
33 |
defaultLegend.setClassifyingFieldTypes(new String[]{FeatureAttributeDescriptor.TYPE_INT}); |
34 |
ISymbol myDefaultSymbol = SymbologyFactory.createDefaultSymbolByShapeType(Geometry.TYPES.GEOMETRY, Color.BLACK);
|
35 |
// ISymbol myDefaultSymbol = SymbologyFactory.createDefaultSymbolByShapeType(Geometry.TYPES.GEOMETRY, Color.BLACK);
|
36 |
defaultLegend.setDefaultSymbol(myDefaultSymbol); |
37 |
colors = new ArrayList(); |
38 |
|
39 |
labeling = new AttrInTableLabelingStrategy();
|
40 |
labeling.setTextFieldId(DXFResource.ID_FIELD_TEXT); |
41 |
labeling.setRotationFieldId(DXFResource.ID_FIELD_ROTATIONTEXT); |
42 |
labeling.setHeightFieldId(DXFResource.ID_FIELD_HEIGHTTEXT); |
43 |
labeling.setUnit(1); //MapContext.NAMES[1] (meters) |
44 |
} |
45 |
|
46 |
public void add(Feature feature, Map params) throws DataException { |
47 |
// Legend
|
48 |
Integer curColor = (Integer) feature.get(DXFResource.ID_FIELD_COLOR); |
49 |
if (!colors.contains(curColor)){
|
50 |
|
51 |
defaultLegend.addSymbol( |
52 |
curColor, |
53 |
SymbologyFactory.createDefaultSymbolByShapeType( |
54 |
Geometry.TYPES.GEOMETRY, |
55 |
AcadColor.getColor(curColor.intValue()) |
56 |
) |
57 |
); |
58 |
colors.add(curColor); |
59 |
} |
60 |
|
61 |
} |
62 |
|
63 |
public Object getDefaultLegend() { |
64 |
return this.defaultLegend; |
65 |
} |
66 |
|
67 |
public Object getLabeling() { |
68 |
return this.labeling; |
69 |
} |
70 |
|
71 |
public void endLoading() { |
72 |
this.colors.clear();
|
73 |
this.colors = null; |
74 |
} |
75 |
|
76 |
public void startLoading(Map params) { |
77 |
// DO NOTHING
|
78 |
} |
79 |
|
80 |
|
81 |
} |