Revision 21571

View differences:

branches/Mobile_Compatible_Hito_1/libFMap_dataFile/src/org/gvsig/data/datastores/vectorial/base/MemoryStore.java
1
/*
2
 * Created on 27-dic-2004
3
 *
4
 * TODO To change the template for this generated file go to
5
 * Window - Preferences - Java - Code Generation - Code and Comments
6
 */
7
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
8
 *
9
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
10
 *
11
 * This program is free software; you can redistribute it and/or
12
 * modify it under the terms of the GNU General Public License
13
 * as published by the Free Software Foundation; either version 2
14
 * of the License, or (at your option) any later version.
15
 *
16
 * This program is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 * GNU General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU General Public License
22
 * along with this program; if not, write to the Free Software
23
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
24
 *
25
 * For more information, contact:
26
 *
27
 *  Generalitat Valenciana
28
 *   Conselleria d'Infraestructures i Transport
29
 *   Av. Blasco Ib??ez, 50
30
 *   46010 VALENCIA
31
 *   SPAIN
32
 *
33
 *      +34 963862235
34
 *   gvsig@gva.es
35
 *      www.gvsig.gva.es
36
 *
37
 *    or
38
 *
39
 *   IVER T.I. S.A
40
 *   Salamanca 50
41
 *   46005 Valencia
42
 *   Spain
43
 *
44
 *   +34 963163400
45
 *   dac@iver.es
46
 */
47
package org.gvsig.data.datastores.vectorial.base;
48

  
49
import java.util.ArrayList;
50

  
51
import org.gvsig.data.CloseException;
52
import org.gvsig.data.vectorial.AbstractFeatureStore;
53
import org.gvsig.data.vectorial.Feature;
54
import org.gvsig.fmap.geom.primitive.Envelope;
55

  
56

  
57
public abstract class MemoryStore extends AbstractFeatureStore{
58
	private ArrayList arrayFeatures = new ArrayList();
59
	private Envelope fullExtent;
60

  
61
	protected void addFeature(Feature feature){
62
		arrayFeatures.add(feature);
63
		Envelope boundsShp=feature.getExtent();
64
		if (boundsShp == null){
65
			return;
66
		}
67
		if (fullExtent == null) {
68
			fullExtent = boundsShp;
69
		} else {
70
			fullExtent.add(boundsShp);
71
		}
72
	}
73
	protected Feature getFeature(int index) {
74
		Feature feature = (Feature) arrayFeatures.get(index);
75

  
76
		return feature;
77
	}
78

  
79
	protected long getFeatureCount() {
80
		return arrayFeatures.size();
81
	}
82

  
83
	public Envelope getFullExtent() {
84
		return fullExtent;
85
	}
86
	protected void doClose() throws CloseException{
87
		arrayFeatures.clear();
88
		fullExtent=null;
89
	}
90
	protected void doDispose() throws CloseException{
91
		close();
92
		arrayFeatures = null;
93
		super.doDispose();
94
	}
95
	protected ArrayList getFeatures(){
96
		return arrayFeatures;
97
	}
98
}
branches/Mobile_Compatible_Hito_1/libFMap_dataFile/src/org/gvsig/data/datastores/vectorial/file/package.html
1
<html>
2
<head>
3
<title>Excepciones de libData</title>
4
<style type="text/css">
5
    span.foldopened { color: white; font-size: xx-small;
6
    border-width: 1; font-family: monospace; padding: 0em 0.25em 0em 0.25em; background: #e0e0e0;
7
    VISIBILITY: visible;
8
    cursor:pointer; }
9

  
10

  
11
    span.foldclosed { color: #666666; font-size: xx-small;
12
    border-width: 1; font-family: monospace; padding: 0em 0.25em 0em 0.25em; background: #e0e0e0;
13
    VISIBILITY: hidden;
14
    cursor:pointer; }
15

  
16
    span.foldspecial { color: #666666; font-size: xx-small; border-style: none solid solid none;
17
    border-color: #CCCCCC; border-width: 1; font-family: sans-serif; padding: 0em 0.1em 0em 0.1em; background: #e0e0e0;
18
    cursor:pointer; }
19

  
20
    li { list-style: none; }
21

  
22
    span.l { color: red; font-weight: bold; }
23

  
24
    a:link {text-decoration: none; color: black; }
25
    a:visited {text-decoration: none; color: black; }
26
    a:active {text-decoration: none; color: black; }
27
    a:hover {text-decoration: none; color: black; background: #eeeee0; }
28

  
29
</style>
30
<!-- ^ Position is not set to relative / absolute here because of Mozilla -->
31
</head>
32
<body>
33
<p>Excepciones de libData
34
<ul><li><span style="color: #000000;font-family: SansSerif, sans-serif; ">DataException</span>
35
<ul><li><span style="color: #000000;font-family: SansSerif, sans-serif; ">ReadException</span>
36
<ul><li><span style="color: #000000;font-family: SansSerif, sans-serif; ">CloseException</span>
37

  
38
</li>
39
<li><span style="color: #000000;font-family: SansSerif, sans-serif; ">EvaluationExpressionException</span>
40

  
41
</li>
42
<li><span style="color: #000000;font-family: SansSerif, sans-serif; ">InitializeException</span>
43
<ul><li><span style="color: #000000;font-family: SansSerif, sans-serif; ">OpenException</span>
44
<ul><li><span style="color: #000000;font-family: SansSerif, sans-serif; ">UnsupportedEncodingException</span>
45

  
46
</li>
47
<li><span style="color: #000000;font-family: SansSerif, sans-serif; ">UnsupportedVersionException</span>
48

  
49
</li>
50
<li>FileNotFoundException
51

  
52
</li>
53

  
54
</ul>
55
</li>
56

  
57
</ul>
58
</li>
59
<li>RemoveFileException
60

  
61
</li>
62

  
63
</ul>
64
</li>
65
<li><span style="color: #000000;font-family: SansSerif, sans-serif; ">WriteException</span>
66
<ul><li><span style="color: #000000;font-family: SansSerif, sans-serif; ">InitializeWriterException</span>
67

  
68
</li>
69
<li><span style="color: #000000;font-family: SansSerif, sans-serif; ">UnsupportedTypeException</span>
70

  
71
</li>
72

  
73
</ul>
74
</li>
75

  
76
</ul>
77
</li>
78

  
79
</ul></body>
80
</html>
branches/Mobile_Compatible_Hito_1/libFMap_dataFile/src/org/gvsig/data/datastores/vectorial/file/FileExplorer.java
1
package org.gvsig.data.datastores.vectorial.file;
2

  
3
import java.io.File;
4

  
5
import org.gvsig.data.DataException;
6
import org.gvsig.data.DataManager;
7
import org.gvsig.data.DataStore;
8
import org.gvsig.data.DataStoreParameters;
9
import org.gvsig.data.NewDataStoreParameters;
10
import org.gvsig.data.InitializeException;
11
import org.gvsig.data.ReadException;
12
import org.gvsig.data.WriteException;
13
import org.gvsig.data.vectorial.FeatureStoreExplorer;
14
import org.gvsig.data.vectorial.NewFeatureStoreParameters;
15

  
16
public abstract class FileExplorer implements FeatureStoreExplorer{
17

  
18
	public boolean canCreate() {
19
		return false;
20
	}
21

  
22
	public DataStore createDataStore(DataStoreParameters dsp) throws InitializeException {
23
		DataManager manager = DataManager.getManager();
24
		return manager.createDataStore(dsp);
25
	}
26

  
27
	protected abstract boolean isValid(String file);
28
	protected abstract boolean isValid(File file);
29

  
30
	public DataStoreParameters add(NewFeatureStoreParameters ndsp) throws WriteException,InitializeException  {
31
		throw new UnsupportedOperationException();
32
	}
33

  
34
	public DataStoreParameters add(NewDataStoreParameters ndsp) throws WriteException, InitializeException {
35
		return this.add((NewFeatureStoreParameters)ndsp);
36
	}
37

  
38
	public void remove(DataStoreParameters dsp) throws ReadException {
39
		throw new UnsupportedOperationException();
40

  
41
	}
42

  
43
	public NewDataStoreParameters createNewDataStoreParameter() {
44
		throw new UnsupportedOperationException();
45
	}
46

  
47
	/* (non-Javadoc)
48
	 * @see org.gvsig.data.DataExplorer#dispose()
49
	 */
50
	public void dispose() throws DataException {
51
		// No operation
52

  
53
	}
54

  
55

  
56

  
57
}
branches/Mobile_Compatible_Hito_1/libFMap_dataFile/src/org/gvsig/data/datastores/vectorial/file/FileMemoryResource.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
*
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
* MA  02110-1301, USA.
20
*
21
*/
22

  
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2008 IVER T.I   {{Task}}
26
*/
27

  
28
/**
29
 *
30
 */
31
package org.gvsig.data.datastores.vectorial.file;
32

  
33
import java.util.ArrayList;
34
import java.util.List;
35

  
36
import org.gvsig.data.DataException;
37
import org.gvsig.data.OpenException;
38
import org.gvsig.data.ReadException;
39
import org.gvsig.data.vectorial.Feature;
40
import org.gvsig.fmap.geom.primitive.Envelope;
41

  
42
/**
43
 * @author jmvivo
44
 *
45
 */
46
public abstract class FileMemoryResource extends FileResource {
47

  
48
	protected List features = null;
49
	private Envelope fullExtent;
50
	private boolean loaded=false;
51
	private boolean loading=false;
52
	/**
53
	 * @param aFile
54
	 */
55
	public FileMemoryResource(FileStoreParameters params) {
56
		super(params);
57
		this.initFeatureList();
58
	}
59

  
60
	protected void initFeatureList(){
61
		this.features = new ArrayList();
62
	}
63

  
64
	protected void addFeature(Feature feature) throws DataException{
65
		if (!this.loading){
66
			throw new DataException("Not loading mode");
67
		}
68
		this.features.add(feature);
69
		Envelope boundsShp=feature.getExtent();
70
		if (boundsShp == null){
71
			return;
72
		}
73
		if (fullExtent == null) {
74
			fullExtent = boundsShp;
75
		} else {
76
			fullExtent.add(boundsShp);
77
		}
78
	}
79

  
80

  
81
	protected abstract void load() throws DataException;
82

  
83
	/* (non-Javadoc)
84
	 * @see org.gvsig.data.Resource#doOpen()
85
	 */
86
	protected boolean doOpen() throws OpenException {
87
		this.setOpened();
88
		if (this.loaded)
89
			return false;
90
		this.loading=true;
91
		try {
92
			this.load();
93
		} catch (DataException e) {
94
			this.loading = false;
95
			throw new OpenException(this.description(),e);
96
		}
97
		this.loading=false;
98
		this.loaded=true;
99
		return true;
100
	}
101

  
102
	protected Feature getFeature(int index) throws ReadException {
103
		this.checkOpen();
104
		Feature feature = (Feature) this.features.get(index);
105
		return feature;
106
	}
107

  
108
	protected int getFeatureCount() throws ReadException {
109
		this.checkOpen();
110
		return this.features.size();
111
	}
112

  
113
	protected Envelope getFullExtent() throws ReadException {
114
		this.checkOpen();
115
		return fullExtent;
116
	}
117

  
118

  
119
}
120

  
0 121

  
branches/Mobile_Compatible_Hito_1/libFMap_dataFile/src/org/gvsig/data/datastores/vectorial/file/FileStoreParameters.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
*
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
* MA  02110-1301, USA.
20
*
21
*/
22

  
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2008 IVER T.I   {{Task}}
26
*/
27

  
28
/**
29
 *
30
 */
31
package org.gvsig.data.datastores.vectorial.file;
32

  
33
import java.io.File;
34

  
35
import org.gvsig.data.DataStoreParameters;
36

  
37
/**
38
 * @author jmvivo
39
 *
40
 */
41
public interface FileStoreParameters extends DataStoreParameters{
42

  
43
	public File getFile();
44
	public void setFile(File aFile);
45
}
46

  
0 47

  
branches/Mobile_Compatible_Hito_1/libFMap_dataFile/src/org/gvsig/data/datastores/vectorial/file/dxf/DXFDataExplorerParameters.java
1
package org.gvsig.data.datastores.vectorial.file.dxf;
2

  
3
import org.gvsig.data.datastores.vectorial.file.FileExplorerParameters;
4

  
5
public class DXFDataExplorerParameters extends FileExplorerParameters {
6

  
7
	public String getDataExplorerName() {
8
		return DXFDataExplorer.DATASOURCE_NAME;
9
	}
10

  
11
}
branches/Mobile_Compatible_Hito_1/libFMap_dataFile/src/org/gvsig/data/datastores/vectorial/file/dxf/DXFStoreParameters.java
1
package org.gvsig.data.datastores.vectorial.file.dxf;
2

  
3
import java.io.File;
4

  
5
import org.cresques.cts.IProjection;
6
import org.gvsig.data.datastores.vectorial.file.FileStoreParameters;
7

  
8

  
9
public class DXFStoreParameters implements FileStoreParameters{
10
	private File dxffile;
11
	private IProjection projection;
12
	public String getDataStoreName() {
13
		return DXFStore.DATASTORE_NAME;
14
	}
15
	public IProjection getProjection() {
16
		return projection;
17
	}
18
	public void setProjection(IProjection projection){
19
		this.projection=projection;
20
	}
21
	public boolean isValid() {
22
		return dxffile != null && this.projection != null;
23
	}
24
	/* (non-Javadoc)
25
	 * @see org.gvsig.data.datastores.vectorial.file.FileStoreParameters#getFile()
26
	 */
27
	public File getFile() {
28
		return dxffile;
29
	}
30
	/* (non-Javadoc)
31
	 * @see org.gvsig.data.datastores.vectorial.file.FileStoreParameters#setFile(java.io.File)
32
	 */
33
	public void setFile(File aFile) {
34
		this.dxffile = aFile;
35
	}
36
}
branches/Mobile_Compatible_Hito_1/libFMap_dataFile/src/org/gvsig/data/datastores/vectorial/file/dxf/Register.java
1
package org.gvsig.data.datastores.vectorial.file.dxf;
2

  
3
import org.gvsig.data.DataManager;
4

  
5
public class Register {
6
	public static void selfRegister() {
7
		DataManager dsm = DataManager.getManager();
8

  
9
		dsm.registerDataStore(DXFStore.DATASTORE_NAME,
10
				DXFStore.class,
11
				DXFStoreParameters.class
12
		);
13
	}
14

  
15

  
16
}
branches/Mobile_Compatible_Hito_1/libFMap_dataFile/src/org/gvsig/data/datastores/vectorial/file/dxf/DXFFeatureCollection.java
1
package org.gvsig.data.datastores.vectorial.file.dxf;
2

  
3
import java.util.Collection;
4

  
5
import org.gvsig.data.vectorial.MemoryFeatureCollection;
6

  
7
public class DXFFeatureCollection extends MemoryFeatureCollection {
8

  
9
	public DXFFeatureCollection(Collection features) {
10
		this.features=features;
11
	}
12
}
branches/Mobile_Compatible_Hito_1/libFMap_dataFile/src/org/gvsig/data/datastores/vectorial/file/dxf/DXFResource.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
*
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
* MA  02110-1301, USA.
20
*
21
*/
22

  
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2008 IVER T.I   {{Task}}
26
*/
27

  
28
/**
29
 *
30
 */
31
package org.gvsig.data.datastores.vectorial.file.dxf;
32

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

  
38
import org.cresques.geo.Point3D;
39
import org.cresques.io.DxfFile;
40
import org.cresques.px.IObjList;
41
import org.cresques.px.dxf.DxfFeatureMaker;
42
import org.cresques.px.dxf.DxfHeaderManager;
43
import org.cresques.px.gml.Feature;
44
import org.cresques.px.gml.LineString;
45
import org.cresques.px.gml.LineString3D;
46
import org.cresques.px.gml.Point;
47
import org.cresques.px.gml.Polygon;
48
import org.cresques.px.gml.Polygon3D;
49
import org.gvsig.data.DataException;
50
import org.gvsig.data.OpenException;
51
import org.gvsig.data.ReadException;
52
import org.gvsig.data.datastores.vectorial.file.FileMemoryResource;
53
import org.gvsig.data.vectorial.AttributeDescriptor;
54
import org.gvsig.data.vectorial.DefaultFeatureType;
55
import org.gvsig.data.vectorial.FeatureAttributeDescriptor;
56
import org.gvsig.data.vectorial.FeatureType;
57
import org.gvsig.data.vectorial.IsNotAttributeSettingException;
58
import org.gvsig.data.vectorial.IsNotFeatureSettingException;
59
import org.gvsig.data.vectorial.MemoryFeature;
60
import org.gvsig.fmap.geom.Geometry;
61
import org.gvsig.fmap.geom.GeometryFactory;
62
import org.gvsig.fmap.geom.GeometryManager;
63
import org.gvsig.fmap.geom.primitive.Envelope;
64
import org.gvsig.fmap.geom.primitive.GeneralPathX;
65
import org.gvsig.fmap.mapcontext.rendering.legend.LegendFactory;
66
import org.gvsig.fmap.mapcontext.rendering.legend.VectorialUniqueValueLegend;
67
import org.gvsig.fmap.mapcontext.rendering.legend.styling.AttrInTableLabelingStrategy;
68
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
69
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbologyFactory;
70

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

  
78
	protected final static int ID_FIELD_FSHAPE = 1;
79

  
80
	protected final static int ID_FIELD_ENTITY = 2;
81

  
82
	protected final static int ID_FIELD_LAYER = 3;
83

  
84
	protected final static int ID_FIELD_COLOR = 4;
85

  
86
	protected final static int ID_FIELD_ELEVATION = 5;
87

  
88
	protected final static int ID_FIELD_THICKNESS = 6;
89

  
90
	protected final static int ID_FIELD_TEXT = 7;
91

  
92
	protected final static int ID_FIELD_HEIGHTTEXT = 8;
93

  
94
	protected final static int ID_FIELD_ROTATIONTEXT = 9;
95

  
96
	private AttrInTableLabelingStrategy labeling;
97

  
98
	private VectorialUniqueValueLegend defaultLegend;
99

  
100
	private FeatureType featureType;
101

  
102

  
103
	DXFResource(DXFStoreParameters params) {
104
		super(params);
105
	}
106

  
107
	/* (non-Javadoc)
108
	 * @see org.gvsig.data.Resource#getName()
109
	 */
110
	public String getName() {
111
		return "DXF";
112
	}
113

  
114
	 private void initializeFeatureType() {
115
		this.featureType= DXFStore.newFeatureType();
116
	 }
117

  
118
	 protected FeatureType getFeatureType() throws ReadException{
119
		 this.checkOpen();
120
		 return this.featureType;
121
	 }
122

  
123

  
124
	/* (non-Javadoc)
125
	 * @see org.gvsig.data.datastores.vectorial.file.FileMemoryResource#getFeature(int)
126
	 */
127
	protected org.gvsig.data.vectorial.Feature getFeature(int index) throws ReadException {
128
		return super.getFeature(index);
129
	}
130

  
131
	/* (non-Javadoc)
132
	 * @see org.gvsig.data.datastores.vectorial.file.FileMemoryResource#getFeatureCount()
133
	 */
134
	protected int getFeatureCount() throws ReadException {
135
		return super.getFeatureCount();
136
	}
137

  
138
	/* (non-Javadoc)
139
	 * @see org.gvsig.data.datastores.vectorial.file.FileMemoryResource#getFullExtent()
140
	 */
141
	protected Envelope getFullExtent() throws ReadException {
142
		return super.getFullExtent();
143
	}
144

  
145
	/* (non-Javadoc)
146
	 * @see org.gvsig.data.datastores.vectorial.file.FileMemoryResource#load()
147
	 */
148
	protected void load() throws DataException {
149
		float heightText = 10;
150
		DxfFile dxfFeatureFile;
151
		DxfFile.EntityFactory featureMaker = new DxfFeatureMaker(((DXFStoreParameters)this.params).getProjection());
152
		DxfFile.VarSettings headerManager = new DxfHeaderManager();
153
		dxfFeatureFile = new DxfFile(((DXFStoreParameters)this.params).getProjection(), this.getFile().getAbsolutePath(),
154
				featureMaker, headerManager);
155
		try {
156
			dxfFeatureFile.load();
157
		} catch (Exception e1) {
158
			throw new OpenException(description(),e1);
159
		}
160
		IObjList.vector features = (IObjList.vector) ((DxfFeatureMaker) featureMaker)
161
				.getObjects();
162
		String acadVersion = (String) ((DxfHeaderManager) headerManager)
163
				.getAcadVersion();
164
		System.out.println("initialize(): acadVersion = " + acadVersion);
165

  
166
		GeometryFactory gFactory = GeometryManager.getInstance().getGeometryFactory();
167

  
168
		if (!featureMaker.isDxf3DFile() && !headerManager.isWritedDxf3D()) { // y no
169
																				// est?n
170
																				// todos
171
																				// a
172
																				// 9999
173
			Feature[] features2D = new Feature[features.size()];
174
			for (int i = 0; i < features.size(); i++) {
175
				Feature fea = (Feature) features.get(i);
176
				if (fea.getGeometry() instanceof org.cresques.px.gml.Point3D) {
177
					Point point = (Point) fea.getGeometry();
178
					Point point2 = new Point();
179
					for (int j = 0; j < point.pointNr(); j++) {
180
						point2.add(point.get(j));
181
					}
182
					point2.setTextPoint(point.isTextPoint());
183
					fea.setGeometry(point2);
184
					features2D[i] = fea;
185
					// } else if (fea.getGeometry() instanceof InsPoint3D) {
186
					// InsPoint insPoint = (InsPoint)fea.getGeometry();
187
					// InsPoint insPoint2 = new InsPoint();
188
					// for (int j=0;j<insPoint.pointNr();j++) {
189
					// insPoint2.add(insPoint.get(j));
190
					// }
191
					// fea.setGeometry(insPoint2);
192
					// features2D[i] = fea;
193
				} else if (fea.getGeometry() instanceof LineString3D) {
194
					LineString lineString = (LineString) fea.getGeometry();
195
					LineString lineString2 = new LineString();
196
					for (int j = 0; j < lineString.pointNr(); j++) {
197
						lineString2.add(lineString.get(j));
198
					}
199
					fea.setGeometry(lineString2);
200
					features2D[i] = fea;
201
				} else if (fea.getGeometry() instanceof Polygon3D) {
202
					Polygon polygon = (Polygon) fea.getGeometry();
203
					Polygon polygon2 = new Polygon();
204
					for (int j = 0; j < polygon.pointNr(); j++) {
205
						polygon2.add(polygon.get(j));
206
					}
207
					fea.setGeometry(polygon2);
208
					features2D[i] = fea;
209
				}
210
			}
211
			features.clear();
212
			for (int i = 0; i < features2D.length; i++) {
213
				features.add(features2D[i]);
214
			}
215
		}
216
		// String acadVersion =
217
		// (String)((DxfHeaderManager)headerManager).getAcadVersion();
218
		// System.out.println("initialize(): acadVersion = " + acadVersion);
219

  
220
		int nAtt = featureMaker.getAttributes().size();
221

  
222
		// Campos de las MemoryLayer:
223

  
224
//		Object[] auxRow = new Object[10 + nAtt];
225
//		ArrayList arrayFields = new ArrayList();
226
//		arrayFields.add("ID");
227
//		arrayFields.add("FShape");
228
//		arrayFields.add("Entity");
229
//		arrayFields.add("Layer");
230
//		arrayFields.add("Color");
231
//		arrayFields.add("Elevation");
232
//		arrayFields.add("Thickness");
233
//		arrayFields.add("Text");
234
//		arrayFields.add("HeightText");
235
//		arrayFields.add("RotationText");
236
		initializeFeatureType();
237

  
238

  
239

  
240

  
241
		for (int i = 0; i < nAtt; i++) {
242
			String att[] = new String[2];
243
			att = (String[]) featureMaker.getAttributes().get(i);
244

  
245
			AttributeDescriptor descriptorAux = (AttributeDescriptor) ((DefaultFeatureType)featureType).createAttributeDescriptor();
246
			try {
247
				descriptorAux.loading();
248
				descriptorAux.setType(FeatureAttributeDescriptor.TYPE_STRING);
249
				descriptorAux.setName(att[0]);
250
				descriptorAux.setDefaultValue("");
251
				descriptorAux.stopLoading();
252
			} catch (IsNotAttributeSettingException e) {
253
				e.printStackTrace();
254
			}
255
			featureType.add(descriptorAux);
256

  
257

  
258
//			arrayFields.add(att[0]);
259
		}
260

  
261
		labeling = new AttrInTableLabelingStrategy();
262
		((AttrInTableLabelingStrategy) labeling).setTextFieldId(ID_FIELD_TEXT);
263
		((AttrInTableLabelingStrategy) labeling).setRotationFieldId(ID_FIELD_ROTATIONTEXT);
264
		((AttrInTableLabelingStrategy) labeling).setHeightFieldId(ID_FIELD_HEIGHTTEXT);
265
		((AttrInTableLabelingStrategy) labeling).setUnit(1); //MapContext.NAMES[1] (meters)
266

  
267
//		getTableModel().setColumnIdentifiers(arrayFields.toArray());
268

  
269
		for (int i = 0; i < features.size(); i++) {
270

  
271
			MemoryFeature feature;
272
			try {
273
				feature = new DXFFeature(featureType,true);
274
			} catch (ReadException e1) {
275
				throw new OpenException(this.description(),e1);
276
			}
277
//			auxRow[ID_FIELD_HEIGHTTEXT] = new Double(0.0);
278
//			auxRow[ID_FIELD_ROTATIONTEXT] = new Double(0.0);
279
//			auxRow[ID_FIELD_TEXT] = null;
280
			try{
281
				feature.loading();
282
				Feature fea = (Feature) features.get(i);
283
				if (fea.getGeometry() instanceof Point
284
						&& !(fea.getGeometry() instanceof org.cresques.px.gml.Point3D)) {
285
					Point point = (Point) fea.getGeometry();
286
					Point2D pto = new Point2D.Double();
287
					pto = point.get(0);
288
//					FShape nuevoShp;
289
					if (point.isTextPoint()) {
290
						feature.set(ID_FIELD_ID,i);
291
//						auxRow[ID_FIELD_ID] = new Integer(i);
292
//						feature.set(ID_FIELD_FSHAPE,"Point2D");
293
//						auxRow[ID_FIELD_FSHAPE] = new String("FPoint2D");
294
						feature.set(ID_FIELD_ENTITY,fea.getProp("dxfEntity"));
295
//						auxRow[ID_FIELD_ENTITY] = new String(fea.getProp("dxfEntity"));
296
						feature.set(ID_FIELD_LAYER,fea.getProp("layer"));
297
//						auxRow[ID_FIELD_LAYER] = new String(fea.getProp("layer"));
298
						int auxInt = Integer.parseInt(fea.getProp("color"));
299
						feature.set(ID_FIELD_COLOR,auxInt);
300
//						auxRow[ID_FIELD_COLOR] = new Integer(auxInt);
301
						feature.set(ID_FIELD_TEXT,fea.getProp("text"));
302
//						auxRow[ID_FIELD_TEXT] = ValueFactory
303
//						.createValue(new String(fea.getProp("text")));
304
						heightText = Float.parseFloat(fea.getProp("textHeight"));
305
						feature.set(ID_FIELD_HEIGHTTEXT,heightText);
306
//						auxRow[ID_FIELD_HEIGHTTEXT] = ValueFactory
307
//						.createValue(heightText);
308
						double auxR = Double.parseDouble(fea
309
								.getProp("textRotation"));
310
						feature.set(ID_FIELD_ROTATIONTEXT,auxR);
311
//						auxRow[ID_FIELD_ROTATIONTEXT] = ValueFactory
312
//						.createValue(auxR);
313
						double auxE = Double.parseDouble(fea.getProp("elevation"));
314
						feature.set(ID_FIELD_ELEVATION,auxE);
315
//						auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(auxE);
316
						double auxT = Double.parseDouble(fea.getProp("thickness"));
317
						feature.set(ID_FIELD_THICKNESS,auxT);
318
//						auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(auxT);
319
						// Attributes
320
						for (int j = 0; j < nAtt; j++) {
321
							String[] attributes = new String[2];
322
							attributes = (String[]) featureMaker.getAttributes()
323
							.get(j);
324
							feature.set(10+j,attributes[1]);
325
//							auxRow[10 + j] = ValueFactory.createValue(new String(
326
//							attributes[1]));
327
							if (!fea.getProp(attributes[0]).equals(attributes[1])) {
328
								feature.set(10+j,fea.getProp(attributes[0]));
329
//								auxRow[10 + j] = ValueFactory
330
//								.createValue(new String(fea
331
//								.getProp(attributes[0])));
332
							}
333
						}
334
						Geometry geom=gFactory.createPoint2D(new org.gvsig.fmap.geom.primitive.Point2D(pto.getX(), pto.getY()));
335
						feature.set(ID_FIELD_FSHAPE,geom);
336
//						feature.setDefaultGeometry(geom);
337
						addFeature(feature);
338

  
339
//						addShape(nuevoShp, auxRow);
340
					} else {
341
						feature.set(ID_FIELD_ID,i);
342
//						auxRow[ID_FIELD_ID] = ValueFactory.createValue(i);
343
//						feature.set(ID_FIELD_FSHAPE,"Point2D");
344
//						auxRow[ID_FIELD_FSHAPE] = ValueFactory
345
//						.createValue(new String("FPoint2D"));
346
						feature.set(ID_FIELD_ENTITY,fea.getProp("dxfEntity"));
347
//						auxRow[ID_FIELD_ENTITY] = ValueFactory
348
//						.createValue(new String(fea.getProp("dxfEntity")));
349
						feature.set(ID_FIELD_LAYER,fea.getProp("layer"));
350
//						auxRow[ID_FIELD_LAYER] = ValueFactory
351
//						.createValue(new String(fea.getProp("layer")));
352
						int auxInt = Integer.parseInt(fea.getProp("color"));
353
						feature.set(ID_FIELD_COLOR,auxInt);
354
//						auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(auxInt);
355
						double auxE = Double.parseDouble(fea.getProp("elevation"));
356
						feature.set(ID_FIELD_ELEVATION,auxE);
357
//						auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(auxE);
358
						double auxT = Double.parseDouble(fea.getProp("thickness"));
359
						feature.set(ID_FIELD_THICKNESS,auxT);
360
//						auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(auxT);
361
						// Attributes
362
						for (int j = 0; j < nAtt; j++) {
363
							String[] attributes = new String[2];
364
							attributes = (String[]) featureMaker.getAttributes()
365
							.get(j);
366
							feature.set(10+j,attributes[1]);
367
//							auxRow[10 + j] = ValueFactory.createValue(new String(
368
//							attributes[1]));
369
							if (!fea.getProp(attributes[0]).equals(attributes[1])) {
370
								feature.set(10+j,fea.getProp(attributes[0]));
371
//								auxRow[10 + j] = ValueFactory
372
//								.createValue(new String(fea
373
//								.getProp(attributes[0])));
374
							}
375
						}
376
						Geometry geom=gFactory.createPoint2D(new org.gvsig.fmap.geom.primitive.Point2D(pto.getX(), pto.getY()));
377
						feature.set(ID_FIELD_FSHAPE,geom);
378
//						feature.setDefaultGeometry(geom);
379
						addFeature(feature);
380
//						addShape(nuevoShp, auxRow);
381
					}
382
				} else if (fea.getGeometry() instanceof org.cresques.px.gml.Point3D) {
383
					org.cresques.px.gml.Point3D point = (org.cresques.px.gml.Point3D) fea
384
					.getGeometry();
385
					Point3D pto = new Point3D();
386
					pto = point.getPoint3D(0);
387
//					FShape nuevoShp;
388
					if (point.isTextPoint()) {
389
						feature.set(ID_FIELD_ID,i);
390
//						auxRow[ID_FIELD_ID] = ValueFactory.createValue(i);
391
						feature.set(ID_FIELD_FSHAPE,"Point3D");
392
//						auxRow[ID_FIELD_FSHAPE] = ValueFactory
393
//						.createValue(new String("FPoint3D"));
394
						feature.set(ID_FIELD_ENTITY,fea.getProp("dxfEntity"));
395
//						auxRow[ID_FIELD_ENTITY] = ValueFactory
396
//						.createValue(new String(fea.getProp("dxfEntity")));
397
						feature.set(ID_FIELD_LAYER,fea.getProp("layer"));
398
//						auxRow[ID_FIELD_LAYER] = ValueFactory
399
//						.createValue(new String(fea.getProp("layer")));
400
						int auxInt = Integer.parseInt(fea.getProp("color"));
401
						feature.set(ID_FIELD_COLOR,auxInt);
402
//						auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(auxInt);
403
						feature.set(ID_FIELD_TEXT,fea.getProp("text"));
404
//						auxRow[ID_FIELD_TEXT] = ValueFactory
405
//						.createValue(new String(fea.getProp("text")));
406
						heightText = Float.parseFloat(fea.getProp("textHeight"));
407
						feature.set(ID_FIELD_HEIGHTTEXT,heightText);
408
//						auxRow[ID_FIELD_HEIGHTTEXT] = ValueFactory
409
//						.createValue(heightText);
410
						double auxR = Double.parseDouble(fea
411
								.getProp("textRotation"));
412
						feature.set(ID_FIELD_ROTATIONTEXT,auxR);
413
//						auxRow[ID_FIELD_ROTATIONTEXT] = ValueFactory
414
//						.createValue(auxR);
415
						double auxE = Double.parseDouble(fea.getProp("elevation"));
416
						feature.set(ID_FIELD_ELEVATION,auxE);
417
//						auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(auxE);
418
						double auxT = Double.parseDouble(fea.getProp("thickness"));
419
						feature.set(ID_FIELD_THICKNESS,auxT);
420
//						auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(auxT);
421
						// Attributes
422
						for (int j = 0; j < nAtt; j++) {
423
							String[] attributes = new String[2];
424
							attributes = (String[]) featureMaker.getAttributes()
425
							.get(j);
426
							feature.set(10+j,attributes[1]);
427
//							auxRow[10 + j] = ValueFactory.createValue(new String(
428
//							attributes[1]));
429
							if (!fea.getProp(attributes[0]).equals(attributes[1])) {
430
								feature.set(10+j,fea.getProp(attributes[0]));
431
//								auxRow[10 + j] = ValueFactory
432
//								.createValue(new String(fea
433
//								.getProp(attributes[0])));
434
							}
435
						}
436
						Geometry geom=gFactory.createPoint3D(pto.getX(), pto.getY(), pto.getZ());
437
						feature.set(ID_FIELD_FSHAPE,geom);
438
//						feature.setDefaultGeometry(geom);
439
						addFeature(feature);
440
//						addShape(nuevoShp, auxRow);
441
					} else {
442
						feature.set(ID_FIELD_ID,i);
443
//						auxRow[ID_FIELD_ID] = ValueFactory.createValue(i);
444
						feature.set(ID_FIELD_FSHAPE,"Point3D");
445
//						auxRow[ID_FIELD_FSHAPE] = ValueFactory
446
//						.createValue(new String("FPoint3D"));
447
						feature.set(ID_FIELD_ENTITY,fea.getProp("dxfEntity"));
448
//						auxRow[ID_FIELD_ENTITY] = ValueFactory
449
//						.createValue(new String(fea.getProp("dxfEntity")));
450
						feature.set(ID_FIELD_LAYER,fea.getProp("layer"));
451
//						auxRow[ID_FIELD_LAYER] = ValueFactory
452
//						.createValue(new String(fea.getProp("layer")));
453
						int auxInt = Integer.parseInt(fea.getProp("color"));
454
						feature.set(ID_FIELD_COLOR,auxInt);
455
//						auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(auxInt);
456

  
457
						double auxE = Double.parseDouble(fea.getProp("elevation"));
458
						feature.set(ID_FIELD_ELEVATION,auxE);
459
//						auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(auxE);
460
						double auxT = Double.parseDouble(fea.getProp("thickness"));
461
						feature.set(ID_FIELD_THICKNESS,auxT);
462
//						auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(auxT);
463
						// Attributes
464
						for (int j = 0; j < nAtt; j++) {
465
							String[] attributes = new String[2];
466
							attributes = (String[]) featureMaker.getAttributes()
467
							.get(j);
468
							feature.set(10+j,attributes[1]);
469
//							auxRow[10 + j] = ValueFactory.createValue(new String(
470
//							attributes[1]));
471
							if (!fea.getProp(attributes[0]).equals(attributes[1])) {
472
								feature.set(10+j,fea.getProp(attributes[0]));
473
//								auxRow[10 + j] = ValueFactory
474
//								.createValue(new String(fea
475
//								.getProp(attributes[0])));
476
							}
477
						}
478
						Geometry geom=gFactory.createPoint3D(pto.getX(), pto.getY(), pto.getZ());
479
						feature.set(ID_FIELD_FSHAPE,geom);
480
//						feature.setDefaultGeometry(geom);
481
						addFeature(feature);
482
//						addShape(nuevoShp, auxRow);
483
					}
484
				} else if (fea.getGeometry() instanceof LineString
485
						&& !(fea.getGeometry() instanceof LineString3D)) {
486
					GeneralPathX genPathX = new GeneralPathX();
487
					Point2D[] pts = new Point2D[fea.getGeometry().pointNr()];
488
					for (int j = 0; j < fea.getGeometry().pointNr(); j++) {
489
						pts[j] = fea.getGeometry().get(j);
490
					}
491
					genPathX.moveTo(pts[0].getX(), pts[0].getY());
492
					for (int j = 1; j < pts.length; j++) {
493
						genPathX.lineTo(pts[j].getX(), pts[j].getY());
494
					}
495
					feature.set(ID_FIELD_ID,i);
496
//					auxRow[ID_FIELD_ID] = ValueFactory.createValue(i);
497
					feature.set(ID_FIELD_FSHAPE,"Polyline2D");
498
//					auxRow[ID_FIELD_FSHAPE] = ValueFactory.createValue(new String(
499
//					"FPolyline2D"));
500
					feature.set(ID_FIELD_ENTITY,fea.getProp("dxfEntity"));
501
//					auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String(
502
//					fea.getProp("dxfEntity")));
503
					feature.set(ID_FIELD_LAYER,fea.getProp("layer"));
504
//					auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(new String(
505
//					fea.getProp("layer")));
506
					int auxInt = Integer.parseInt(fea.getProp("color"));
507
					feature.set(ID_FIELD_COLOR,auxInt);
508
//					auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(auxInt);
509
					double auxE = Double.parseDouble(fea.getProp("elevation"));
510
					feature.set(ID_FIELD_ELEVATION,auxE);
511
//					auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(auxE);
512
					double auxT = Double.parseDouble(fea.getProp("thickness"));
513
					feature.set(ID_FIELD_THICKNESS,auxT);
514
//					auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(auxT);
515
					// Attributes
516
					for (int j = 0; j < nAtt; j++) {
517
						String[] attributes = new String[2];
518
						attributes = (String[]) featureMaker.getAttributes().get(j);
519
						feature.set(10+j,attributes[1]);
520
//						auxRow[10 + j] = ValueFactory.createValue(new String(
521
//						attributes[1]));
522
						if (!fea.getProp(attributes[0]).equals(attributes[1])) {
523
							feature.set(10+j,fea.getProp(attributes[0]));
524
//							auxRow[10 + j] = ValueFactory.createValue(new String(
525
//							fea.getProp(attributes[0])));
526
						}
527
					}
528
					Geometry geom=gFactory.createPolyline2D(genPathX);
529
					feature.set(ID_FIELD_FSHAPE,geom);
530
//					feature.setDefaultGeometry(geom);
531
					addFeature(feature);
532
//					addShape(nuevoShp, auxRow);
533
				} else if (fea.getGeometry() instanceof LineString3D) {
534
					GeneralPathX genPathX = new GeneralPathX();
535
					Point3D[] pts = new Point3D[fea.getGeometry().pointNr()];
536
					for (int j = 0; j < fea.getGeometry().pointNr(); j++) {
537
						pts[j] = ((LineString3D) fea.getGeometry()).getPoint3D(j);
538
					}
539
					genPathX.moveTo(pts[0].getX(), pts[0].getY());
540
					for (int j = 1; j < pts.length; j++) {
541
						genPathX.lineTo(pts[j].getX(), pts[j].getY());
542
					}
543
					double[] elevations = new double[pts.length];
544
					for (int j = 0; j < pts.length; j++) {
545
						elevations[j] = pts[j].getZ();
546
					}
547
					feature.set(ID_FIELD_ID,i);
548
//					auxRow[ID_FIELD_ID] = ValueFactory.createValue(i);
549
					feature.set(ID_FIELD_FSHAPE,"Polyline3D");
550
//					auxRow[ID_FIELD_FSHAPE] = ValueFactory.createValue(new String(
551
//					"FPolyline3D"));
552
					feature.set(ID_FIELD_ENTITY,fea.getProp("dxfEntity"));
553
//					auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String(
554
//					fea.getProp("dxfEntity")));
555
					feature.set(ID_FIELD_LAYER,fea.getProp("layer"));
556
//					auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(new String(
557
//					fea.getProp("layer")));
558
					int auxInt = Integer.parseInt(fea.getProp("color"));
559
					feature.set(ID_FIELD_COLOR,auxInt);
560
//					auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(auxInt);
561
					if (fea.getProp("elevation") != null) {
562
						double auxE = Double.parseDouble(fea.getProp("elevation"));
563
						feature.set(ID_FIELD_ELEVATION,auxE);
564
//						auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(auxE);
565
					}
566
					double auxT = Double.parseDouble(fea.getProp("thickness"));
567
					feature.set(ID_FIELD_THICKNESS,auxT);
568
//					auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(auxT);
569
					// Attributes
570
					for (int j = 0; j < nAtt; j++) {
571
						String[] attributes = new String[2];
572
						attributes = (String[]) featureMaker.getAttributes().get(j);
573
						feature.set(10+j,attributes[1]);
574
//						auxRow[10 + j] = ValueFactory.createValue(new String(
575
//						attributes[1]));
576
						if (!fea.getProp(attributes[0]).equals(attributes[1])) {
577
							feature.set(10+j,fea.getProp(attributes[0]));
578
//							auxRow[10 + j] = ValueFactory.createValue(new String(
579
//							fea.getProp(attributes[0])));
580
						}
581
					}
582
					Geometry geom=gFactory.createPolyline3D(genPathX,elevations);
583
					feature.set(ID_FIELD_FSHAPE,geom);
584
//					feature.setDefaultGeometry(geom);
585
					addFeature(feature);
586
//					addShape(nuevoShp, auxRow);
587
				} else if (fea.getGeometry() instanceof Polygon
588
						&& !(fea.getGeometry() instanceof Polygon3D)) {
589
					GeneralPathX genPathX = new GeneralPathX();
590
					// 050112: A?ado una posici?n m?s para el punto que cierra y
591
					// creo el objeto firstPt.
592
					Point2D firstPt = new Point2D.Double();
593
					firstPt = fea.getGeometry().get(0);
594
					Point2D[] pts = new Point2D[fea.getGeometry().pointNr() + 1];
595
					for (int j = 0; j < fea.getGeometry().pointNr(); j++) {
596
						pts[j] = fea.getGeometry().get(j);
597
					}
598
					// 050112: A?ado el primer punto al final para cerrar los
599
					// pol?gonos.
600
					pts[fea.getGeometry().pointNr()] = firstPt;
601
					genPathX.moveTo(pts[0].getX(), pts[0].getY());
602
					for (int j = 1; j < pts.length; j++) {
603
						genPathX.lineTo(pts[j].getX(), pts[j].getY());
604
					}
605
					feature.set(ID_FIELD_ID,i);
606
//					auxRow[ID_FIELD_ID] = ValueFactory.createValue(i);
607
					feature.set(ID_FIELD_FSHAPE,"Polygon2D");
608
//					auxRow[ID_FIELD_FSHAPE] = ValueFactory.createValue(new String(
609
//					"FPolygon2D"));
610
					feature.set(ID_FIELD_ENTITY,fea.getProp("dxfEntity"));
611
//					auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String(
612
//					fea.getProp("dxfEntity")));
613
					feature.set(ID_FIELD_LAYER,fea.getProp("layer"));
614
//					auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(new String(
615
//					fea.getProp("layer")));
616
					int auxInt = Integer.parseInt(fea.getProp("color"));
617
					feature.set(ID_FIELD_COLOR,auxInt);
618
//					auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(auxInt);
619
					double auxE = Double.parseDouble(fea.getProp("elevation"));
620
					feature.set(ID_FIELD_ELEVATION,auxE);
621
//					auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(auxE);
622
					double auxT = Double.parseDouble(fea.getProp("thickness"));
623
					feature.set(ID_FIELD_THICKNESS,auxT);
624
//					auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(auxT);
625
					// Attributes
626
					for (int j = 0; j < nAtt; j++) {
627
						String[] attributes = new String[2];
628
						attributes = (String[]) featureMaker.getAttributes().get(j);
629
						feature.set(10+j,attributes[1]);
630
//						auxRow[10 + j] = ValueFactory.createValue(new String(
631
//						attributes[1]));
632
						if (!fea.getProp(attributes[0]).equals(attributes[1])) {
633
							feature.set(10+j,fea.getProp(attributes[0]));
634
//							auxRow[10 + j] = ValueFactory.createValue(new String(
635
//							fea.getProp(attributes[0])));
636
						}
637
					}
638
					Geometry geom=gFactory.createPolygon2D(genPathX);
639
					feature.set(ID_FIELD_FSHAPE,geom);
640
//					feature.setDefaultGeometry(geom);
641
					addFeature(feature);
642
//					addShape(nuevoShp, auxRow);
643
				} else if (fea.getGeometry() instanceof Polygon3D) {
644
					GeneralPathX genPathX = new GeneralPathX();
645
					// 050112: A?ado una posici?n m?s para el punto que cierra y
646
					// creo el objeto firstPt.
647
					Point3D firstPt = new Point3D();
648
					firstPt = ((Polygon3D) fea.getGeometry())
649
					.getPoint3D(0);
650
					Point3D[] pts = new Point3D[fea.getGeometry().pointNr() + 1];
651
					for (int j = 0; j < fea.getGeometry().pointNr(); j++) {
652
						pts[j] = ((Polygon3D) fea.getGeometry())
653
						.getPoint3D(j);
654
					}
655
					// 050112: A?ado el primer punto al final para cerrar los
656
					// pol?gonos.
657
					pts[fea.getGeometry().pointNr()] = firstPt;
658
					genPathX.moveTo(pts[0].getX(), pts[0].getY());
659
					for (int j = 1; j < pts.length; j++) {
660
						genPathX.lineTo(pts[j].getX(), pts[j].getY());
661
					}
662
					double[] elevations = new double[pts.length];
663
					for (int j = 0; j < pts.length; j++) {
664
						elevations[j] = pts[j].getZ();
665
					}
666
					feature.set(ID_FIELD_ID,i);
667
//					auxRow[ID_FIELD_ID] = ValueFactory.createValue(i);
668
					feature.set(ID_FIELD_FSHAPE,"Polygon3D");
669
//					auxRow[ID_FIELD_FSHAPE] = ValueFactory.createValue(new String(
670
//					"FPolygon3D"));
671
					feature.set(ID_FIELD_ENTITY,fea.getProp("dxfEntity"));
672
//					auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String(
673
//					fea.getProp("dxfEntity")));
674
					feature.set(ID_FIELD_LAYER,fea.getProp("layer"));
675
//					auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(new String(
676
//					fea.getProp("layer")));
677
					int auxInt = Integer.parseInt(fea.getProp("color"));
678
					feature.set(ID_FIELD_COLOR,auxInt);
679
//					auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(auxInt);
680
					if (fea.getProp("elevation") != null) {
681
						double auxE = Double.parseDouble(fea.getProp("elevation"));
682
						feature.set(ID_FIELD_ELEVATION,auxE);
683
//						auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(auxE);
684
					}
685
					double auxT = Double.parseDouble(fea.getProp("thickness"));
686
					feature.set(ID_FIELD_THICKNESS,auxT);
687
//					auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(auxT);
688
					// Attributes
689
					for (int j = 0; j < nAtt; j++) {
690
						String[] attributes = new String[2];
691
						attributes = (String[]) featureMaker.getAttributes().get(j);
692
						feature.set(10+j,attributes[1]);
693
//						auxRow[10 + j] = ValueFactory.createValue(new String(
694
//						attributes[1]));
695
						if (!fea.getProp(attributes[0]).equals(attributes[1])) {
696
							feature.set(10+j,fea.getProp(attributes[0]));
697
//							auxRow[10 + j] = ValueFactory.createValue(new String(
698
//							fea.getProp(attributes[0])));
699
						}
700
					}
701
					Geometry geom=gFactory.createPolygon3D(genPathX,elevations);
702
					feature.set(ID_FIELD_FSHAPE,geom);
703
//					feature.setDefaultGeometry(geom);
704
					addFeature(feature);
705
//					addShape(nuevoShp, auxRow);
706
				} else {
707
					// System.out.println("Detectado feature desconocido");
708
				}
709
				feature.stopLoading();
710
			}catch (IsNotFeatureSettingException e) {
711
				e.printStackTrace();
712
			}
713
		}
714

  
715
		defaultLegend = LegendFactory
716
				.createVectorialUniqueValueLegend(Geometry.TYPES.AGGREGATE);
717
		defaultLegend.setClassifyingFieldNames(new String[] {"Color"});
718
		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});
719

  
720
		Logger.getAnonymousLogger().info("DXFStore: should check if this is a text symbol");
721
		ISymbol myDefaultSymbol = SymbologyFactory.
722
			createDefaultSymbolByShapeType(Geometry.TYPES.AGGREGATE, Color.BLACK);
723

  
724
		defaultLegend.setDefaultSymbol(myDefaultSymbol);
725

  
726
//		ISymbol theSymbol = null;
727
//
728
//			for (long j = 0; j < featuresAux.size(); j++) {
729
//				Feature feat=(Feature)featuresAux.get((int)j);
730
//				int clave=feat.getInt(ID_FIELD_COLOR);
731
////				clave = (IntValue) rs.getFieldValue(j, ID_FIELD_COLOR);
732
//				if (defaultLegend.getSymbolByValue(clave) == null) {
733
//					theSymbol = SymbologyFactory.
734
//						createDefaultSymbolByShapeType(
735
//								FShape.MULTI,
736
//								AcadColor.getColor(clave.getValue()));
737
//					theSymbol.setDescription(clave.toString());
738
//					// Asigna los colores de Autocad a los
739
//					// bordes
740
//					// de los pol?gonos.
741
//					if (theSymbol instanceof IFillSymbol) {
742
//						((IFillSymbol) theSymbol).getOutline().setLineColor(AcadColor.getColor(clave
743
//								.getValue()));
744
//
745
//					}
746
//					defaultLegend.addSymbol(clave, theSymbol);
747
//				}
748
//			} // for
749

  
750
	}
751

  
752

  
753

  
754
	/* (non-Javadoc)
755
	 * @see org.gvsig.data.datastores.vectorial.file.IFileResource#getTotalFiles()
756
	 */
757
	public int getTotalFiles() {
758
		return 1;
759
	}
760

  
761
	/* (non-Javadoc)
762
	 * @see org.gvsig.data.datastores.vectorial.file.FileResource#editing()
763
	 */
764
	protected void editing() {
765
		super.editing();
766
	}
767

  
768
	/* (non-Javadoc)
769
	 * @see org.gvsig.data.datastores.vectorial.file.FileResource#isEditing()
770
	 */
771
	protected boolean isEditing() {
772
		return super.isEditing();
773
	}
774

  
775
	/* (non-Javadoc)
776
	 * @see org.gvsig.data.datastores.vectorial.file.FileResource#stopEditing()
777
	 */
778
	protected void stopEditing() {
779
		super.stopEditing();
780
	}
781

  
782
}
783

  
0 784

  
branches/Mobile_Compatible_Hito_1/libFMap_dataFile/src/org/gvsig/data/datastores/vectorial/file/dxf/DXFFeatureID.java
1
package org.gvsig.data.datastores.vectorial.file.dxf;
2

  
3
import org.gvsig.data.vectorial.Feature;
4
import org.gvsig.data.vectorial.FeatureID;
5
import org.gvsig.data.vectorial.MemoryFeatureID;
6

  
7
class DXFFeatureID extends MemoryFeatureID implements FeatureID{
8

  
9
	public DXFFeatureID(Feature feature) {
10
		super(feature);
11
	}
12
}
branches/Mobile_Compatible_Hito_1/libFMap_dataFile/src/org/gvsig/data/datastores/vectorial/file/dxf/DXFDataExplorer.java
1
package org.gvsig.data.datastores.vectorial.file.dxf;
2

  
3
import java.io.File;
4
import java.util.ArrayList;
5

  
6
import org.gvsig.data.DataExplorerParameters;
7
import org.gvsig.data.DataStoreParameters;
8
import org.gvsig.data.NewDataStoreParameters;
9
import org.gvsig.data.InitializeException;
10
import org.gvsig.data.ReadException;
11
import org.gvsig.data.datastores.vectorial.InitializeWriterException;
12
import org.gvsig.data.datastores.vectorial.file.FileExplorer;
13
import org.gvsig.data.datastores.vectorial.file.FileNotFoundException;
14
import org.gvsig.data.datastores.vectorial.file.RemoveFileException;
15
import org.gvsig.data.vectorial.FeatureType;
16
import org.gvsig.data.vectorial.NewFeatureStoreParameters;
17

  
18
public class DXFDataExplorer extends FileExplorer {
19
	public static String DATASOURCE_NAME="DXFDataSource";
20
    protected DXFDataExplorerParameters parameters;
21
	protected File path;
22

  
23

  
24
	public DataStoreParameters[] list() throws ReadException {
25
		if (!this.path.exists()){
26
			new FileNotFoundException(this.getName()+": Path not found '"+this.path+"'",new Exception());
27
		}
28
//		DataManager dsm=DataManager.getManager();
29

  
30
		String files[] = this.path.list();
31
		int i;
32
		File theFile;
33
		ArrayList fileList = new ArrayList();
34
		DataStoreParameters dsp = null;
35

  
36
		for (i=0;i<files.length;i++){
37
			theFile = new File(this.path,files[i]);
38

  
39
			if (this.isValid(theFile)){
40
				dsp= this.newParameter(theFile);
41
				fileList.add(dsp);
42

  
43
			}
44

  
45

  
46
		}
47
		DataStoreParameters[] x = new DataStoreParameters[1];
48
		x[0]=dsp;
49
		return (DataStoreParameters[])fileList.toArray(x);
50
	}
51

  
52
	protected DataStoreParameters newParameter(){
53
		return new DXFStoreParameters();
54
	}
55

  
56
	protected DataStoreParameters newParameter(File file){
57
		DXFStoreParameters param = (DXFStoreParameters) this.newParameter();
58
		param.setFile(file);
59
		return param;
60
	}
61

  
62
	protected boolean isValid(String file){
63
		return this.isValid(new File(file));
64

  
65
	}
66

  
67
	protected boolean isValid(File file){
68
		if (!file.exists()){
69
			return false;
70
		}
71
		return (file.getName().toLowerCase().endsWith(".dxf"));
72
	}
73

  
74
	public String getName() {
75
		return DATASOURCE_NAME;
76
	}
77

  
78
	public void init(DataExplorerParameters parameters) {
79
		this.parameters = (DXFDataExplorerParameters)parameters;
80
		this.path = this.parameters.getSource();
81
	}
82

  
83
	public boolean canCreate() {
84
		return true;
85
	}
86

  
87
	public DataStoreParameters add(NewFeatureStoreParameters ndsp) throws InitializeWriterException, InitializeException {
88
		DataStoreParameters dsp=ndsp.getDataStoreParameters();
89

  
90

  
91

  
92
		return dsp;
93
	}
94

  
95
	public NewDataStoreParameters createNewDataStoreParameter() {
96
		DXFNewStoreParameters dbfnsp=new DXFNewStoreParameters();
97
		dbfnsp.init(this.newParameter());
98
		return dbfnsp;
99
	}
100

  
101
	public void remove(DataStoreParameters dsp) throws RemoveFileException {
102
		DXFStoreParameters dxfsp=(DXFStoreParameters)dsp;
103
		File f=dxfsp.getFile();
104
		if (f.exists()) {
105
			if (!f.delete()){
106
				throw new RemoveFileException(this.getName(),new Exception());
107
			}
108
		}
109

  
110
	}
111

  
112
	public FeatureType[] getFeatureTypes(DataStoreParameters dsp) throws ReadException {
113
		return new FeatureType[] {DXFStore.newFeatureType()};
114
	}
115
}
branches/Mobile_Compatible_Hito_1/libFMap_dataFile/src/org/gvsig/data/datastores/vectorial/file/dxf/DXFNewStoreParameters.java
1
package org.gvsig.data.datastores.vectorial.file.dxf;
2

  
3
import org.gvsig.data.vectorial.AbstractNewFeatureStoreParameter;
4

  
5
public class DXFNewStoreParameters extends AbstractNewFeatureStoreParameter{
6

  
7
	public DXFNewStoreParameters() {
8
		// TODO Auto-generated constructor stub
9
	}
10

  
11
	public String getDataStoreName() {
12
		return DXFStore.DATASTORE_NAME;
13
	}
14

  
15
	public boolean isValid() {
16
		// TODO Auto-generated method stub
17
		return false;
18
	}
19

  
20
}
branches/Mobile_Compatible_Hito_1/libFMap_dataFile/src/org/gvsig/data/datastores/vectorial/file/dxf/DXFFeature.java
1
package org.gvsig.data.datastores.vectorial.file.dxf;
2

  
3
import org.gvsig.data.DataException;
4
import org.gvsig.data.ReadException;
5
import org.gvsig.data.vectorial.Feature;
6
import org.gvsig.data.vectorial.FeatureType;
7
import org.gvsig.data.vectorial.MemoryFeature;
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff