Revision 23303 branches/v2_0_0_prep/libraries/libFMap_dataFile/src/org/gvsig/fmap/data/feature/file/dxf/DXFResource.java

View differences:

DXFResource.java
30 30
 */
31 31
package org.gvsig.fmap.data.feature.file.dxf;
32 32

  
33
import java.awt.Color;
34 33
import java.awt.geom.Point2D;
35
import java.util.logging.Logger;
36 34

  
37 35
import org.cresques.cts.IProjection;
38 36
import org.cresques.geo.Point3D;
......
58 56
import org.gvsig.fmap.data.feature.IsNotFeatureSettingException;
59 57
import org.gvsig.fmap.data.feature.MemoryFeature;
60 58
import org.gvsig.fmap.data.feature.file.FileMemoryResource;
59
import org.gvsig.fmap.data.feature.operation.LegendLabelingManager;
60
import org.gvsig.fmap.data.feature.operation.LegendLabelingManagerFactory;
61 61
import org.gvsig.fmap.geom.Geometry;
62 62
import org.gvsig.fmap.geom.GeometryFactory;
63 63
import org.gvsig.fmap.geom.GeometryManager;
64 64
import org.gvsig.fmap.geom.primitive.Envelope;
65 65
import org.gvsig.fmap.geom.primitive.GeneralPathX;
66
import org.gvsig.fmap.mapcontext.rendering.legend.LegendFactory;
67
import org.gvsig.fmap.mapcontext.rendering.legend.VectorialUniqueValueLegend;
68
import org.gvsig.fmap.mapcontext.rendering.legend.styling.AttrInTableLabelingStrategy;
69
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
70
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbologyFactory;
71 66

  
72 67
/**
73 68
 * @author jmvivo
74 69
 *
75 70
 */
76 71
public class DXFResource extends FileMemoryResource {
77
	protected final static int ID_FIELD_ID = 0;
78 72

  
79
	protected final static int ID_FIELD_GEOMETRY = 1;
73
	private static LegendLabelingManagerFactory legendLabelingManagerFactory = null;
80 74

  
81
	protected final static int ID_FIELD_ENTITY = 2;
75
	public final static int ID_FIELD_ID = 0;
82 76

  
83
	protected final static int ID_FIELD_LAYER = 3;
77
	public final static int ID_FIELD_GEOMETRY = 1;
84 78

  
85
	protected final static int ID_FIELD_COLOR = 4;
79
	public final static int ID_FIELD_ENTITY = 2;
86 80

  
87
	protected final static int ID_FIELD_ELEVATION = 5;
81
	public final static int ID_FIELD_LAYER = 3;
88 82

  
89
	protected final static int ID_FIELD_THICKNESS = 6;
83
	public final static int ID_FIELD_COLOR = 4;
90 84

  
91
	protected final static int ID_FIELD_TEXT = 7;
85
	public final static int ID_FIELD_ELEVATION = 5;
92 86

  
93
	protected final static int ID_FIELD_HEIGHTTEXT = 8;
87
	public final static int ID_FIELD_THICKNESS = 6;
94 88

  
95
	protected final static int ID_FIELD_ROTATIONTEXT = 9;
89
	public final static int ID_FIELD_TEXT = 7;
96 90

  
97
	private AttrInTableLabelingStrategy labeling;
91
	public final static int ID_FIELD_HEIGHTTEXT = 8;
98 92

  
99
	private VectorialUniqueValueLegend defaultLegend;
93
	public final static int ID_FIELD_ROTATIONTEXT = 9;
100 94

  
95
	private LegendLabelingManager legendlabelingManager;
96

  
101 97
	private FeatureType featureType;
102 98

  
103 99

  
100

  
104 101
	DXFResource(DXFStoreParameters params) {
105 102
		super(params);
106 103
	}
......
156 153
		dxfFeatureFile = new DxfFile(projection, this.getFile()
157 154
				.getAbsolutePath(),
158 155
				featureMaker, headerManager);
156

  
157
		if (legendLabelingManagerFactory != null) {
158
			legendlabelingManager = legendLabelingManagerFactory.newManager();
159
			legendlabelingManager.startLoading(null);
160
		} else {
161
			legendlabelingManager = null;
162
		}
163

  
159 164
		try {
160 165
			dxfFeatureFile.load();
161 166
		} catch (Exception e1) {
......
262 267
//			arrayFields.add(att[0]);
263 268
		}
264 269

  
265
		labeling = new AttrInTableLabelingStrategy();
266
		(labeling).setTextFieldId(ID_FIELD_TEXT);
267
		(labeling).setRotationFieldId(ID_FIELD_ROTATIONTEXT);
268
		(labeling).setHeightFieldId(ID_FIELD_HEIGHTTEXT);
269
		(labeling).setUnit(1); //MapContext.NAMES[1] (meters)
270

  
271 270
//		getTableModel().setColumnIdentifiers(arrayFields.toArray());
272 271

  
273 272
		for (int i = 0; i < features.size(); i++) {
......
716 715
			}
717 716
		}
718 717

  
719
		defaultLegend = LegendFactory
720
				.createVectorialUniqueValueLegend(Geometry.TYPES.GEOMETRY);
721
		defaultLegend.setClassifyingFieldNames(new String[] {"Color"});
722
		defaultLegend.setClassifyingFieldTypes(new String[]{FeatureAttributeDescriptor.TYPE_INT,FeatureAttributeDescriptor.TYPE_STRING,FeatureAttributeDescriptor.TYPE_STRING,FeatureAttributeDescriptor.TYPE_STRING,FeatureAttributeDescriptor.TYPE_INT,FeatureAttributeDescriptor.TYPE_DOUBLE,FeatureAttributeDescriptor.TYPE_DOUBLE});
718
		if (legendlabelingManager != null) {
719
			legendlabelingManager.endLoading();
720
		}
723 721

  
724
		Logger.getAnonymousLogger().info("DXFStore: should check if this is a text symbol");
725
		ISymbol myDefaultSymbol = SymbologyFactory.
726
			createDefaultSymbolByShapeType(Geometry.TYPES.GEOMETRY, Color.BLACK);
727 722

  
728
		defaultLegend.setDefaultSymbol(myDefaultSymbol);
729

  
730 723
//		ISymbol theSymbol = null;
731 724
//
732 725
//			for (long j = 0; j < featuresAux.size(); j++) {
......
754 747
	}
755 748

  
756 749
	private void addDXFFeature(org.gvsig.fmap.data.feature.Feature feature) throws DataException{
757
		this.addFeature(new DXFFeature(feature));
750
		DXFFeature newFeature = new DXFFeature(feature);
751
		this.addFeature(newFeature);
752
		if (this.legendlabelingManager != null) {
753
			this.legendlabelingManager.add(newFeature, null);
754
		}
755

  
758 756
	}
759 757

  
760 758
	/* (non-Javadoc)
......
785 783
		super.stopEditing();
786 784
	}
787 785

  
788
	protected VectorialUniqueValueLegend getDefaultLegend() throws ReadException{
786
	protected Object getDefaultLegend() throws ReadException {
789 787
		this.checkOpen();
790
		return defaultLegend;
788
		if (legendlabelingManager == null) {
789
			return null;
790
		}
791
		return legendlabelingManager.getDefaultLegend();
791 792
	}
792 793

  
793
	protected AttrInTableLabelingStrategy getDefaultLabelingStrategy()  throws ReadException {
794
	protected Object getDefaultLabelingStrategy() throws ReadException {
794 795
		this.checkOpen();
795
		return labeling;
796
		if (legendlabelingManager == null) {
797
			return null;
798
		}
799
		return legendlabelingManager.getLabeling();
796 800
	}
797 801

  
802
	public static void setLegendLabelingManagerFactory(
803
			LegendLabelingManagerFactory factory) {
804
		legendLabelingManagerFactory = factory;
805
	}
806

  
807
	public static LegendLabelingManagerFactory getLegendLabelingManagerFactory() {
808
		return legendLabelingManagerFactory;
809
	}
810

  
798 811
}
799 812

  

Also available in: Unified diff