root / branches / v2_0_0_prep / libraries / libFMap_data_dwg / src / org / gvsig / fmap / data / feature / file / dwg / operation / DWGLegendLabelingManager.java @ 23273
History | View | Annotate | Download (2.29 KB)
1 |
package org.gvsig.fmap.data.feature.file.dwg.operation; |
---|---|
2 |
|
3 |
import java.awt.Color; |
4 |
import java.util.ArrayList; |
5 |
|
6 |
import org.gvsig.fmap.data.DataException; |
7 |
import org.gvsig.fmap.data.feature.Feature; |
8 |
import org.gvsig.fmap.data.feature.FeatureAttributeDescriptor; |
9 |
import org.gvsig.fmap.data.feature.file.dwg.DWGResource; |
10 |
import org.gvsig.fmap.data.feature.operation.LegendLabelingManager; |
11 |
import org.gvsig.fmap.geom.Geometry; |
12 |
import org.gvsig.fmap.mapcontext.rendering.legend.LegendFactory; |
13 |
import org.gvsig.fmap.mapcontext.rendering.legend.VectorialUniqueValueLegend; |
14 |
import org.gvsig.fmap.mapcontext.rendering.legend.styling.AttrInTableLabelingStrategy; |
15 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
16 |
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbologyFactory; |
17 |
|
18 |
import com.iver.cit.jdwglib.util.AcadColor; |
19 |
|
20 |
public class DWGLegendLabelingManager implements LegendLabelingManager { |
21 |
private AttrInTableLabelingStrategy labeling;
|
22 |
private VectorialUniqueValueLegend defaultLegend;
|
23 |
private ArrayList colors; |
24 |
|
25 |
protected DWGLegendLabelingManager(){
|
26 |
// Legend
|
27 |
defaultLegend = LegendFactory.createVectorialUniqueValueLegend(Geometry.TYPES.GEOMETRY); |
28 |
defaultLegend.setClassifyingFieldNames(new String[] {"Color"}); |
29 |
|
30 |
defaultLegend.setClassifyingFieldTypes(new String[]{FeatureAttributeDescriptor.TYPE_INT}); |
31 |
ISymbol myDefaultSymbol = SymbologyFactory.createDefaultSymbolByShapeType(Geometry.TYPES.GEOMETRY, Color.BLACK);
|
32 |
defaultLegend.setDefaultSymbol(myDefaultSymbol); |
33 |
colors = new ArrayList(); |
34 |
|
35 |
|
36 |
labeling = new AttrInTableLabelingStrategy();
|
37 |
labeling.setTextFieldId(DWGResource.ID_FIELD_TEXT); |
38 |
labeling.setRotationFieldId(DWGResource.ID_FIELD_ROTATIONTEXT); |
39 |
labeling.setHeightFieldId(DWGResource.ID_FIELD_HEIGHTTEXT); |
40 |
labeling.setUnit(1); //MapContext.NAMES[1] (meters) |
41 |
} |
42 |
|
43 |
public void add(Feature feature) throws DataException { |
44 |
// Legend
|
45 |
Integer curColor = (Integer) feature.get(DWGResource.ID_FIELD_COLOR); |
46 |
if (!colors.contains(curColor)){
|
47 |
|
48 |
defaultLegend.addSymbol( |
49 |
curColor, |
50 |
SymbologyFactory.createDefaultSymbolByShapeType( |
51 |
Geometry.TYPES.GEOMETRY, |
52 |
AcadColor.getColor(curColor.intValue()) |
53 |
) |
54 |
); |
55 |
colors.add(curColor); |
56 |
} |
57 |
|
58 |
} |
59 |
|
60 |
public Object getDefaultLegend() { |
61 |
return this.defaultLegend; |
62 |
} |
63 |
|
64 |
public Object getLabeling() { |
65 |
return this.labeling; |
66 |
} |
67 |
|
68 |
|
69 |
} |