Revision 331
org.gvsig.dxf/tags/org.gvsig.dxf-2.0.76/org.gvsig.dxf.app/org.gvsig.dxf.app.mainplugin/src/main/resources-plugin/config.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1"?> |
|
2 |
<plugin-config> |
|
3 |
<libraries library-dir="lib/"/> |
|
4 |
<depends plugin-name="org.gvsig.app.mainplugin"/> |
|
5 |
<depends plugin-name="org.gvsig.exportto.app.mainplugin" optional="true"/> |
|
6 |
<resourceBundle name="text"/> |
|
7 |
<extensions> |
|
8 |
<extension class-name="org.gvsig.andami.LibraryExtension" active="false"/> |
|
9 |
</extensions> |
|
10 |
</plugin-config> |
org.gvsig.dxf/tags/org.gvsig.dxf-2.0.76/org.gvsig.dxf.app/org.gvsig.dxf.app.mainplugin/src/main/assembly/gvsig-plugin-package.xml | ||
---|---|---|
1 |
<assembly> |
|
2 |
<id>gvsig-plugin-package</id> |
|
3 |
<formats> |
|
4 |
<format>zip</format> |
|
5 |
</formats> |
|
6 |
<baseDirectory>${project.artifactId}</baseDirectory> |
|
7 |
<includeBaseDirectory>true</includeBaseDirectory> |
|
8 |
<files> |
|
9 |
<file> |
|
10 |
<source>target/${project.artifactId}-${project.version}.jar</source> |
|
11 |
<outputDirectory>lib</outputDirectory> |
|
12 |
</file> |
|
13 |
<file> |
|
14 |
<source>target/package.info</source> |
|
15 |
</file> |
|
16 |
</files> |
|
17 |
|
|
18 |
<fileSets> |
|
19 |
<fileSet> |
|
20 |
<directory>src/main/resources-plugin</directory> |
|
21 |
<outputDirectory>.</outputDirectory> |
|
22 |
</fileSet> |
|
23 |
</fileSets> |
|
24 |
|
|
25 |
<dependencySets> |
|
26 |
<dependencySet> |
|
27 |
<useProjectArtifact>false</useProjectArtifact> |
|
28 |
<useTransitiveDependencies>false</useTransitiveDependencies> |
|
29 |
<outputDirectory>lib</outputDirectory> |
|
30 |
<includes> |
|
31 |
<include>org.gvsig:org.gvsig.dxf.provider.legend</include> |
|
32 |
<include>org.gvsig:org.gvsig.dxf.provider</include> |
|
33 |
<include>org.gvsig:org.gvsig.dxf.lib</include> |
|
34 |
<include>org.gvsig:org.gvsig.dxf.exportto</include> |
|
35 |
</includes> |
|
36 |
</dependencySet> |
|
37 |
</dependencySets> |
|
38 |
|
|
39 |
</assembly> |
org.gvsig.dxf/tags/org.gvsig.dxf-2.0.76/org.gvsig.dxf.app/org.gvsig.dxf.app.mainplugin/pom.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
|
|
3 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|
4 |
|
|
5 |
<modelVersion>4.0.0</modelVersion> |
|
6 |
<artifactId>org.gvsig.dxf.app.mainplugin</artifactId> |
|
7 |
<packaging>jar</packaging> |
|
8 |
<name>${project.artifactId}</name> |
|
9 |
<description>DXF file format support</description> |
|
10 |
<parent> |
|
11 |
<groupId>org.gvsig</groupId> |
|
12 |
<artifactId>org.gvsig.dxf.app</artifactId> |
|
13 |
<version>2.0.76</version> |
|
14 |
</parent> |
|
15 |
|
|
16 |
<dependencies> |
|
17 |
<dependency> |
|
18 |
<groupId>org.gvsig</groupId> |
|
19 |
<artifactId>org.gvsig.tools.lib</artifactId> |
|
20 |
<scope>compile</scope> |
|
21 |
</dependency> |
|
22 |
<dependency> |
|
23 |
<groupId>org.gvsig</groupId> |
|
24 |
<artifactId>org.gvsig.andami</artifactId> |
|
25 |
<scope>compile</scope> |
|
26 |
</dependency> |
|
27 |
<dependency> |
|
28 |
<groupId>org.gvsig</groupId> |
|
29 |
<artifactId>org.gvsig.dxf.provider</artifactId> |
|
30 |
<scope>compile</scope> |
|
31 |
</dependency> |
|
32 |
<dependency> |
|
33 |
<groupId>org.gvsig</groupId> |
|
34 |
<artifactId>org.gvsig.dxf.lib</artifactId> |
|
35 |
<scope>runtime</scope> |
|
36 |
</dependency> |
|
37 |
<dependency> |
|
38 |
<groupId>org.gvsig</groupId> |
|
39 |
<artifactId>org.gvsig.dxf.exportto</artifactId> |
|
40 |
<scope>runtime</scope> |
|
41 |
</dependency> |
|
42 |
<dependency> |
|
43 |
<groupId>org.gvsig</groupId> |
|
44 |
<artifactId>org.gvsig.dxf.provider.legend</artifactId> |
|
45 |
<scope>compile</scope> |
|
46 |
</dependency> |
|
47 |
|
|
48 |
</dependencies> |
|
49 |
|
|
50 |
<properties> |
|
51 |
<!-- Package info property values --> |
|
52 |
<!-- Default values in org.gvsig.desktop --> |
|
53 |
<gvsig.package.info.name>Formats: DXF file format support</gvsig.package.info.name> |
|
54 |
<gvsig.package.info.state>testing</gvsig.package.info.state> |
|
55 |
<gvsig.package.info.official>true</gvsig.package.info.official> |
|
56 |
<gvsig.package.info.dependencies>required: org.gvsig.app.mainplugin -ge 2.1.0-A</gvsig.package.info.dependencies> |
|
57 |
<gvsig.package.info.categories>Formats,Vector</gvsig.package.info.categories> |
|
58 |
<gvsig.package.info.poolURL>https://devel.gvsig.org/download/projects/gvsig-dxf/pool</gvsig.package.info.poolURL> |
|
59 |
</properties> |
|
60 |
|
|
61 |
|
|
62 |
</project> |
org.gvsig.dxf/tags/org.gvsig.dxf-2.0.76/org.gvsig.dxf.app/org.gvsig.dxf.app.mainplugin/buildNumber.properties | ||
---|---|---|
1 |
#Sun Sep 10 22:42:38 CEST 2017 |
|
2 |
buildNumber=2132 |
|
0 | 3 |
org.gvsig.dxf/tags/org.gvsig.dxf-2.0.76/org.gvsig.dxf.app/pom.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
|
|
3 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|
4 |
|
|
5 |
<modelVersion>4.0.0</modelVersion> |
|
6 |
<artifactId>org.gvsig.dxf.app</artifactId> |
|
7 |
<packaging>pom</packaging> |
|
8 |
<name>${project.artifactId}</name> |
|
9 |
<parent> |
|
10 |
<groupId>org.gvsig</groupId> |
|
11 |
<artifactId>org.gvsig.dxf</artifactId> |
|
12 |
<version>2.0.76</version> |
|
13 |
</parent> |
|
14 |
|
|
15 |
<modules> |
|
16 |
<module>org.gvsig.dxf.app.mainplugin</module> |
|
17 |
</modules> |
|
18 |
|
|
19 |
|
|
20 |
</project> |
org.gvsig.dxf/tags/org.gvsig.dxf-2.0.76/org.gvsig.dxf.exportto/src/main/resources/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.exportto.swing.prov.dxf.ExporttoDXFProviderLibrary |
org.gvsig.dxf/tags/org.gvsig.dxf-2.0.76/org.gvsig.dxf.exportto/src/main/java/org/gvsig/exportto/swing/prov/dxf/ExporttoDXFProvider.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
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 3 |
|
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 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.exportto.swing.prov.dxf; |
|
25 |
|
|
26 |
import org.cresques.cts.IProjection; |
|
27 |
|
|
28 |
import org.gvsig.exportto.ExporttoService; |
|
29 |
import org.gvsig.exportto.swing.prov.file.AbstractExporttoFileProvider; |
|
30 |
import org.gvsig.exportto.swing.spi.ExporttoSwingProvider; |
|
31 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
32 |
import org.gvsig.tools.service.spi.ProviderServices; |
|
33 |
|
|
34 |
/** |
|
35 |
* Exporto provider which gets Exporto from a file. |
|
36 |
* |
|
37 |
* @author gvSIG Team |
|
38 |
* @version $Id$ |
|
39 |
*/ |
|
40 |
public class ExporttoDXFProvider extends AbstractExporttoFileProvider implements |
|
41 |
ExporttoSwingProvider { |
|
42 |
|
|
43 |
/** |
|
44 |
* Constructor. |
|
45 |
* |
|
46 |
* @param providerServices |
|
47 |
* the services for the provider |
|
48 |
* @param file |
|
49 |
* to get the Exporto from |
|
50 |
*/ |
|
51 |
public ExporttoDXFProvider(ProviderServices providerServices, |
|
52 |
FeatureStore featureStore, IProjection projection) { |
|
53 |
super(providerServices, featureStore, projection); |
|
54 |
} |
|
55 |
|
|
56 |
public ExporttoService createExporttoService() { |
|
57 |
return new ExporttoDXFService(selectFileOptionPanel.getSelectedFile(), |
|
58 |
featureStore, projection); |
|
59 |
} |
|
60 |
} |
org.gvsig.dxf/tags/org.gvsig.dxf-2.0.76/org.gvsig.dxf.exportto/src/main/java/org/gvsig/exportto/swing/prov/dxf/ExporttoDXFProviderLibrary.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
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 3 |
|
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 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.exportto.swing.prov.dxf; |
|
25 |
|
|
26 |
import org.gvsig.exportto.swing.ExporttoSwingLibrary; |
|
27 |
import org.gvsig.exportto.swing.spi.ExporttoSwingProviderLocator; |
|
28 |
import org.gvsig.tools.library.AbstractLibrary; |
|
29 |
import org.gvsig.tools.library.LibraryException; |
|
30 |
import org.gvsig.tools.service.spi.ProviderManager; |
|
31 |
|
|
32 |
/** |
|
33 |
* Library to initialize and register the file Exporto provider |
|
34 |
* implementation. |
|
35 |
* |
|
36 |
* @author gvSIG Team |
|
37 |
* @version $Id$ |
|
38 |
*/ |
|
39 |
public class ExporttoDXFProviderLibrary extends AbstractLibrary { |
|
40 |
|
|
41 |
@Override |
|
42 |
public void doRegistration() { |
|
43 |
registerAsServiceOf(ExporttoSwingLibrary.class); |
|
44 |
} |
|
45 |
|
|
46 |
@Override |
|
47 |
protected void doInitialize() throws LibraryException { |
|
48 |
// Nothing to do |
|
49 |
} |
|
50 |
|
|
51 |
@Override |
|
52 |
protected void doPostInitialize() throws LibraryException { |
|
53 |
ProviderManager providerManager = |
|
54 |
ExporttoSwingProviderLocator.getManager(); |
|
55 |
providerManager.addProviderFactory(new ExporttoDXFProviderFactory()); |
|
56 |
} |
|
57 |
|
|
58 |
} |
org.gvsig.dxf/tags/org.gvsig.dxf-2.0.76/org.gvsig.dxf.exportto/src/main/java/org/gvsig/exportto/swing/prov/dxf/ExporttoDXFService.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
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 3 |
|
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 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.exportto.swing.prov.dxf; |
|
25 |
|
|
26 |
import java.io.File; |
|
27 |
|
|
28 |
import org.cresques.cts.IProjection; |
|
29 |
|
|
30 |
import org.gvsig.exportto.ExporttoService; |
|
31 |
import org.gvsig.exportto.ExporttoServiceException; |
|
32 |
import org.gvsig.exportto.swing.prov.file.AbstractExporttoFileService; |
|
33 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
34 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
35 |
import org.gvsig.fmap.dal.feature.NewFeatureStoreParameters; |
|
36 |
import org.gvsig.fmap.dal.feature.OpenFeatureStoreParameters; |
|
37 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters; |
|
38 |
import org.gvsig.tools.task.SimpleTaskStatus; |
|
39 |
|
|
40 |
/** |
|
41 |
* @author gvSIG Team |
|
42 |
* @version $Id$ |
|
43 |
* |
|
44 |
*/ |
|
45 |
public class ExporttoDXFService extends AbstractExporttoFileService implements |
|
46 |
ExporttoService { |
|
47 |
|
|
48 |
private IProjection projection; |
|
49 |
|
|
50 |
private NewFeatureStoreParameters newFeatureStoreParameters; |
|
51 |
|
|
52 |
public ExporttoDXFService(File dxfFile, FeatureStore featureStore, |
|
53 |
IProjection projection) { |
|
54 |
super(dxfFile, featureStore); |
|
55 |
if( !dxfFile.getName().toLowerCase().endsWith(".dxf") ) { |
|
56 |
this.file = new File(dxfFile.getAbsolutePath()+".dxf"); |
|
57 |
} |
|
58 |
this.projection = projection; |
|
59 |
try { |
|
60 |
this.open(); |
|
61 |
} catch (ExporttoServiceException e) { |
|
62 |
((SimpleTaskStatus) getTaskStatus()).message(e.getMessage()); |
|
63 |
} |
|
64 |
} |
|
65 |
|
|
66 |
public NewFeatureStoreParameters getNewFeatureStoreParameters() { |
|
67 |
return newFeatureStoreParameters; |
|
68 |
} |
|
69 |
|
|
70 |
@Override |
|
71 |
public void addParameters( |
|
72 |
NewFeatureStoreParameters newFeatureStoreParameters) { |
|
73 |
newFeatureStoreParameters.setDynValue("CRS", projection); |
|
74 |
((FilesystemStoreParameters)newFeatureStoreParameters).setFile(file); |
|
75 |
} |
|
76 |
|
|
77 |
@Override |
|
78 |
public void addParameters( |
|
79 |
OpenFeatureStoreParameters openFeatureStoreParameters) { |
|
80 |
openFeatureStoreParameters.setDynValue("CRS", projection); |
|
81 |
((FilesystemStoreParameters)openFeatureStoreParameters).setFile(file); |
|
82 |
} |
|
83 |
|
|
84 |
@Override |
|
85 |
public String getFileExtension() { |
|
86 |
return "dxf"; |
|
87 |
} |
|
88 |
} |
org.gvsig.dxf/tags/org.gvsig.dxf-2.0.76/org.gvsig.dxf.exportto/src/main/java/org/gvsig/exportto/swing/prov/dxf/ExporttoDXFProviderFactory.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
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 3 |
|
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 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.exportto.swing.prov.dxf; |
|
25 |
|
|
26 |
import org.cresques.cts.IProjection; |
|
27 |
|
|
28 |
import org.gvsig.exportto.swing.ExporttoSwingManager; |
|
29 |
import org.gvsig.exportto.swing.prov.file.AbstractExporttoFileProviderFactory; |
|
30 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
31 |
import org.gvsig.tools.dynobject.DynObject; |
|
32 |
import org.gvsig.tools.service.ServiceException; |
|
33 |
import org.gvsig.tools.service.spi.Provider; |
|
34 |
import org.gvsig.tools.service.spi.ProviderServices; |
|
35 |
|
|
36 |
/** |
|
37 |
* Factory of file {@link ExportoProvider} objects. |
|
38 |
* |
|
39 |
* @author gvSIG Team |
|
40 |
* @version $Id$ |
|
41 |
*/ |
|
42 |
public class ExporttoDXFProviderFactory extends |
|
43 |
AbstractExporttoFileProviderFactory { |
|
44 |
|
|
45 |
private static final String PROVIDER_NAME = "DXF"; |
|
46 |
|
|
47 |
public ExporttoDXFProviderFactory() { |
|
48 |
super(new int[] { ExporttoSwingManager.VECTORIAL_TABLE_WITH_GEOMETRY }); |
|
49 |
} |
|
50 |
|
|
51 |
public Provider create(DynObject parameters, ProviderServices services) |
|
52 |
throws ServiceException { |
|
53 |
return new ExporttoDXFProvider(services, |
|
54 |
(FeatureStore) parameters.getDynValue(PARAMETER_FEATURESTORE), |
|
55 |
(IProjection) parameters.getDynValue(PARAMETER_PROJECTION)); |
|
56 |
} |
|
57 |
|
|
58 |
public String getName() { |
|
59 |
return PROVIDER_NAME; |
|
60 |
} |
|
61 |
} |
org.gvsig.dxf/tags/org.gvsig.dxf-2.0.76/org.gvsig.dxf.exportto/src/main/java/org/gvsig/exportto/swing/prov/dxf/package.html | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8" ?> |
|
2 |
<!-- |
|
3 |
|
|
4 |
gvSIG. Desktop Geographic Information System. |
|
5 |
|
|
6 |
Copyright (C) 2007-2013 gvSIG Association. |
|
7 |
|
|
8 |
This program is free software; you can redistribute it and/or |
|
9 |
modify it under the terms of the GNU General Public License |
|
10 |
as published by the Free Software Foundation; either version 3 |
|
11 |
of the License, or (at your option) any later version. |
|
12 |
|
|
13 |
This program is distributed in the hope that it will be useful, |
|
14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
GNU General Public License for more details. |
|
17 |
|
|
18 |
You should have received a copy of the GNU General Public License |
|
19 |
along with this program; if not, write to the Free Software |
|
20 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
21 |
MA 02110-1301, USA. |
|
22 |
|
|
23 |
For any additional information, do not hesitate to contact us |
|
24 |
at info AT gvsig.com, or visit our website www.gvsig.com. |
|
25 |
|
|
26 |
--> |
|
27 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|
28 |
<html xmlns="http://www.w3.org/1999/xhtml"> |
|
29 |
<head> |
|
30 |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
|
31 |
<title>org.gvsig.exporto package documentation</title> |
|
32 |
</head> |
|
33 |
<body> |
|
34 |
|
|
35 |
<p>Exporto provider which gets Exporto from a file.</p> |
|
36 |
|
|
37 |
</body> |
|
38 |
</html> |
org.gvsig.dxf/tags/org.gvsig.dxf-2.0.76/org.gvsig.dxf.exportto/pom.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1"?> |
|
2 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> |
|
3 |
<modelVersion>4.0.0</modelVersion> |
|
4 |
<artifactId>org.gvsig.dxf.exportto</artifactId> |
|
5 |
<packaging>jar</packaging> |
|
6 |
<name>${project.artifactId}</name> |
|
7 |
<parent> |
|
8 |
<groupId>org.gvsig</groupId> |
|
9 |
<artifactId>org.gvsig.dxf</artifactId> |
|
10 |
<version>2.0.76</version> |
|
11 |
</parent> |
|
12 |
|
|
13 |
<dependencies> |
|
14 |
<dependency> |
|
15 |
<groupId>org.gvsig</groupId> |
|
16 |
<artifactId>org.gvsig.exportto.swing.api</artifactId> |
|
17 |
</dependency> |
|
18 |
<dependency> |
|
19 |
<groupId>org.gvsig</groupId> |
|
20 |
<artifactId>org.gvsig.exportto.swing.spi</artifactId> |
|
21 |
</dependency> |
|
22 |
<dependency> |
|
23 |
<groupId>org.gvsig</groupId> |
|
24 |
<artifactId>org.gvsig.exportto.swing.prov.file</artifactId> |
|
25 |
</dependency> |
|
26 |
<dependency> |
|
27 |
<groupId>org.gvsig</groupId> |
|
28 |
<artifactId>org.gvsig.tools.swing.api</artifactId> |
|
29 |
<scope>compile</scope> |
|
30 |
</dependency> |
|
31 |
<dependency> |
|
32 |
<groupId>org.gvsig</groupId> |
|
33 |
<artifactId>org.gvsig.tools.lib</artifactId> |
|
34 |
<scope>compile</scope> |
|
35 |
</dependency> |
|
36 |
<dependency> |
|
37 |
<groupId>org.gvsig</groupId> |
|
38 |
<artifactId>org.gvsig.fmap.dal.api</artifactId> |
|
39 |
<scope>compile</scope> |
|
40 |
</dependency> |
|
41 |
<dependency> |
|
42 |
<groupId>org.gvsig</groupId> |
|
43 |
<artifactId>org.gvsig.fmap.geometry.api</artifactId> |
|
44 |
<scope>compile</scope> |
|
45 |
</dependency> |
|
46 |
<dependency> |
|
47 |
<groupId>org.gvsig</groupId> |
|
48 |
<artifactId>org.gvsig.projection.api</artifactId> |
|
49 |
<scope>compile</scope> |
|
50 |
</dependency> |
|
51 |
<dependency> |
|
52 |
<groupId>org.gvsig</groupId> |
|
53 |
<artifactId>org.gvsig.metadata.lib.basic.api</artifactId> |
|
54 |
<scope>compile</scope> |
|
55 |
</dependency> |
|
56 |
</dependencies> |
|
57 |
</project> |
|
58 |
|
|
59 |
|
|
0 | 60 |
org.gvsig.dxf/tags/org.gvsig.dxf-2.0.76/org.gvsig.dxf.lib/src/main/java/org/gvsig/dxf/io/DxfGroup.java | ||
---|---|---|
1 |
/* |
|
2 |
* Cresques Mapping Suite. Graphic Library for constructing mapping applications. |
|
3 |
* |
|
4 |
* Copyright (C) 2004-5. |
|
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
19 |
* |
|
20 |
* For more information, contact: |
|
21 |
* |
|
22 |
* cresques@gmail.com |
|
23 |
*/ |
|
24 |
package org.gvsig.dxf.io; |
|
25 |
|
|
26 |
import java.io.BufferedReader; |
|
27 |
import java.io.IOException; |
|
28 |
import java.text.DecimalFormat; |
|
29 |
import java.text.DecimalFormatSymbols; |
|
30 |
import java.util.Locale; |
|
31 |
|
|
32 |
|
|
33 |
/** |
|
34 |
* Grupo Dxf (code, data). Auxiliar para leer ficheros dxf |
|
35 |
* |
|
36 |
* @author "Luis W. Sevilla" <sevilla_lui@gva.es> |
|
37 |
* @author "Michel Michaud" (code from) |
|
38 |
*/ |
|
39 |
public class DxfGroup { |
|
40 |
/* |
|
41 |
def get_group(handle): |
|
42 |
_code = int(handle.readline()) |
|
43 |
_dfun = get_data_type(_code) |
|
44 |
_data = _dfun(handle.readline()) |
|
45 |
return (_code, _data) |
|
46 |
*/ |
|
47 |
private static final DecimalFormatSymbols dfs = new DecimalFormatSymbols(Locale.US); |
|
48 |
private static final DecimalFormat[] decimalFormats = new DecimalFormat[] { |
|
49 |
new DecimalFormat("#0", |
|
50 |
dfs), |
|
51 |
new DecimalFormat("#0.0", |
|
52 |
dfs), |
|
53 |
new DecimalFormat("#0.00", |
|
54 |
dfs), |
|
55 |
new DecimalFormat("#0.000", |
|
56 |
dfs), |
|
57 |
new DecimalFormat("#0.0000", |
|
58 |
dfs), |
|
59 |
new DecimalFormat("#0.00000", |
|
60 |
dfs), |
|
61 |
new DecimalFormat("#0.000000", |
|
62 |
dfs), |
|
63 |
new DecimalFormat("#0.0000000", |
|
64 |
dfs), |
|
65 |
new DecimalFormat("#0.00000000", |
|
66 |
dfs), |
|
67 |
new DecimalFormat("#0.000000000", |
|
68 |
dfs), |
|
69 |
new DecimalFormat("#0.0000000000", |
|
70 |
dfs), |
|
71 |
new DecimalFormat("#0.00000000000", |
|
72 |
dfs), |
|
73 |
new DecimalFormat("#0.000000000000", |
|
74 |
dfs) |
|
75 |
}; |
|
76 |
int code; |
|
77 |
Object data; |
|
78 |
|
|
79 |
/** |
|
80 |
* Constructor por defecto. |
|
81 |
*/ |
|
82 |
public DxfGroup() { |
|
83 |
code = -1; |
|
84 |
data = null; |
|
85 |
} |
|
86 |
|
|
87 |
/** |
|
88 |
* Constructor habitual. Representa una entidad individual dentro del DXF |
|
89 |
* @param code, �ndice del dato dentro del DxfGroup |
|
90 |
* @param data, el propio dato que queda almacenado en el DxfGroup |
|
91 |
*/ |
|
92 |
public DxfGroup(int code, String data) { |
|
93 |
this.code = code; |
|
94 |
this.data = data; |
|
95 |
} |
|
96 |
|
|
97 |
/** |
|
98 |
* Lee una entidad del DXF y la empaqueta en un DxfGroup. |
|
99 |
* @param fi, BufferedReader mediante el cual accedemos al DXF |
|
100 |
* @return DxfGroup con la informaci�n procedente del DXF |
|
101 |
* @throws NumberFormatException |
|
102 |
* @throws IOException |
|
103 |
*/ |
|
104 |
public static DxfGroup read(BufferedReader fi) |
|
105 |
throws NumberFormatException, IOException { |
|
106 |
DxfGroup grp = null; |
|
107 |
String txt = fi.readLine(); |
|
108 |
|
|
109 |
if (txt != null) { |
|
110 |
if (!txt.equals("")) { |
|
111 |
grp = new DxfGroup(); |
|
112 |
grp.code = Integer.parseInt(txt.trim()); |
|
113 |
grp.readData(fi); |
|
114 |
} else { |
|
115 |
// Se trata de una linea en blanco y no se hace nada. |
|
116 |
} |
|
117 |
} |
|
118 |
|
|
119 |
return grp; |
|
120 |
} |
|
121 |
|
|
122 |
/** |
|
123 |
* Devuelve el code |
|
124 |
* @return |
|
125 |
*/ |
|
126 |
public int getCode() { |
|
127 |
return code; |
|
128 |
} |
|
129 |
|
|
130 |
/** |
|
131 |
* Devuelve data |
|
132 |
* @return |
|
133 |
*/ |
|
134 |
public Object getData() { |
|
135 |
return data; |
|
136 |
} |
|
137 |
|
|
138 |
/** |
|
139 |
* Lee un dato individual dentro de un DxfGroup |
|
140 |
* @param fi, BufferedReader |
|
141 |
* @throws IOException |
|
142 |
*/ |
|
143 |
private void readData(BufferedReader fi) throws IOException { |
|
144 |
String txt = fi.readLine().trim(); |
|
145 |
|
|
146 |
if ((0 <= code) && (code <= 9)) { |
|
147 |
data = txt; //_dfun = string_data |
|
148 |
} else if ((10 <= code) && (code <= 59)) { |
|
149 |
data = new Double(Double.parseDouble(txt)); //_dfun = float_data |
|
150 |
} else if ((60 <= code) && (code <= 79)) { |
|
151 |
try { |
|
152 |
data = new Integer(Integer.parseInt(txt)); //_dfun = int_data // 16-bit int |
|
153 |
} catch (java.lang.NumberFormatException e) { |
|
154 |
data = new Integer((int) Double.parseDouble(txt)); |
|
155 |
} |
|
156 |
} else if ((90 <= code) && (code <= 99)) { |
|
157 |
data = new Integer(Integer.parseInt(txt)); //_dfun = int_data // 32-bit int |
|
158 |
} else if (code == 100) { |
|
159 |
data = txt; //_dfun = unicode_data |
|
160 |
} else if (code == 102) { |
|
161 |
// Fran: Comentado para ganar velocidad. |
|
162 |
//System.err. ("Dxf: codigo " + code + " no implementado."); //_dfun = unicode_data |
|
163 |
} else if (code == 105) { |
|
164 |
data = txt; |
|
165 |
; //_dfun = handle_data |
|
166 |
} else if ((110 <= code) && (code <= 139)) { |
|
167 |
data = new Double(Double.parseDouble(txt)); //_dfun = float_data // not in dxf spec |
|
168 |
} else if ((140 <= code) && (code <= 149)) { // says 147 in dxf spec |
|
169 |
data = new Double(Double.parseDouble(txt)); //_dfun = float_data |
|
170 |
} else if ((170 <= code) && (code <= 179)) { // says 175 in dxf spec |
|
171 |
data = new Integer(Integer.parseInt(txt)); //_dfun = int_data // 16-bit int |
|
172 |
} else if ((210 <= code) && (code <= 239)) { |
|
173 |
data = new Double(Double.parseDouble(txt)); //_dfun = float_data // del TEXT procendente de exportacion de microstation |
|
174 |
} else if ((270 <= code) && (code <= 279)) { |
|
175 |
data = new Integer(Integer.parseInt(txt)); //_dfun = int_data // not in dxf spec |
|
176 |
} else if ((280 <= code) && (code <= 289)) { |
|
177 |
data = new Integer(Integer.parseInt(txt)); //_dfun = int_data // 8-bit int |
|
178 |
} else if ((290 <= code) && (code <= 299)) { |
|
179 |
data = new Boolean(Boolean.getBoolean(txt)); //_dfun = bool_data |
|
180 |
} else if ((300 <= code) && (code <= 309)) { |
|
181 |
data = txt; //_dfun = string_data |
|
182 |
} else if ((310 <= code) && (code <= 319)) { |
|
183 |
//_dfun = bin_data |
|
184 |
//throw new IOException("Dxf: codigo "+code+" no implementado."); |
|
185 |
} else if ((320 <= code) && (code <= 329)) { |
|
186 |
//_dfun = handle_data |
|
187 |
//throw new IOException("Dxf: codigo "+code+" no implementado."); |
|
188 |
} else if ((330 <= code) && (code <= 369)) { |
|
189 |
// Fran: Comentado para ganar velocidad. |
|
190 |
//System.err. ("Dxf: codigo " + code + " no implementado."); //_dfun = hex_data |
|
191 |
} else if ((370 <= code) && (code <= 379)) { |
|
192 |
data = new Integer(Integer.parseInt(txt)); //_dfun = int_data // 8-bit int |
|
193 |
} else if ((380 <= code) && (code <= 389)) { |
|
194 |
data = new Integer(Integer.parseInt(txt)); //_dfun = int_data // 8-bit int |
|
195 |
} else if ((390 <= code) && (code <= 399)) { |
|
196 |
data = txt; //_dfun = handle_data |
|
197 |
} else if ((400 <= code) && (code <= 409)) { |
|
198 |
data = new Integer(Integer.parseInt(txt)); //_dfun = int_data // 16-bit int |
|
199 |
} else if ((410 <= code) && (code <= 419)) { |
|
200 |
data = txt; //_dfun = string_data |
|
201 |
} else if (code == 999) { |
|
202 |
data = txt; //_dfun = string_data // comment |
|
203 |
} else if ((1000 <= code) && (code <= 1009)) { |
|
204 |
data = txt; //_dfun = string_data |
|
205 |
} else if ((1010 <= code) && (code <= 1059)) { |
|
206 |
data = new Double(Double.parseDouble(txt)); //_dfun = float_data |
|
207 |
} else if ((1060 <= code) && (code <= 1070)) { |
|
208 |
data = new Integer(Integer.parseInt(txt)); //_dfun = int_data // 16-bit int |
|
209 |
} else if (code == 1071) { |
|
210 |
data = new Integer(Integer.parseInt(txt)); //_dfun = int_data # 32-bit int |
|
211 |
} else { |
|
212 |
throw new IOException("DxfReader: c�digo " + code + |
|
213 |
" desconocido."); |
|
214 |
|
|
215 |
//raise ValueError, "Unexpected code: %d" % code |
|
216 |
} |
|
217 |
|
|
218 |
//return _dfun |
|
219 |
} |
|
220 |
|
|
221 |
/** |
|
222 |
* Permite comparar dos objetos de la clase DxfGroup |
|
223 |
* @param c, code |
|
224 |
* @param s, data |
|
225 |
* @return boolean |
|
226 |
*/ |
|
227 |
public boolean equals(int c, String s) { |
|
228 |
if ((c == code) && (s.compareTo((String) data) == 0)) { |
|
229 |
return true; |
|
230 |
} |
|
231 |
|
|
232 |
return false; |
|
233 |
} |
|
234 |
|
|
235 |
/** |
|
236 |
* Devuelve un dato concreto en forma de String tabulado |
|
237 |
* @param code |
|
238 |
* @return String |
|
239 |
*/ |
|
240 |
public static String int34car(int code) { |
|
241 |
if (code < 10) { |
|
242 |
return " " + Integer.toString(code); |
|
243 |
} else if (code < 100) { |
|
244 |
return " " + Integer.toString(code); |
|
245 |
} else { |
|
246 |
return Integer.toString(code); |
|
247 |
} |
|
248 |
} |
|
249 |
|
|
250 |
/** |
|
251 |
* Devuelve un dato concreto en forma de String tabulado |
|
252 |
* @param value |
|
253 |
* @return String |
|
254 |
*/ |
|
255 |
public static String int6car(int value) { |
|
256 |
String s = " " + Integer.toString(value); |
|
257 |
|
|
258 |
return s.substring(s.length() - 6, s.length()); |
|
259 |
} |
|
260 |
|
|
261 |
/** |
|
262 |
* Convierte a String un dato del DxfGroup |
|
263 |
* @param code |
|
264 |
* @param value |
|
265 |
* @return String |
|
266 |
*/ |
|
267 |
public static String toString(int code, String value) { |
|
268 |
return int34car(code) + "\r\n" + value + "\r\n"; |
|
269 |
} |
|
270 |
|
|
271 |
/** |
|
272 |
* Convierte a String un dato del DxfGroup |
|
273 |
* @param code |
|
274 |
* @param value |
|
275 |
* @return String |
|
276 |
*/ |
|
277 |
public static String toString(int code, int value) { |
|
278 |
return int34car(code) + "\r\n" + int6car(value) + "\r\n"; |
|
279 |
} |
|
280 |
|
|
281 |
/** |
|
282 |
* Convierte a String un dato del DxfGroup |
|
283 |
* @param code |
|
284 |
* @param value |
|
285 |
* @param decimalPartLength |
|
286 |
* @return String |
|
287 |
*/ |
|
288 |
public static String toString(int code, float value, int decimalPartLength) { |
|
289 |
return int34car(code) + "\r\n" + |
|
290 |
decimalFormats[decimalPartLength].format((double) value) + |
|
291 |
"\r\n"; |
|
292 |
} |
|
293 |
|
|
294 |
/** |
|
295 |
* Convierte a String un dato del DxfGroup |
|
296 |
* @param code |
|
297 |
* @param value |
|
298 |
* @param decimalPartLength |
|
299 |
* @return String |
|
300 |
*/ |
|
301 |
public static String toString(int code, double value, int decimalPartLength) { |
|
302 |
return int34car(code) + "\r\n" + |
|
303 |
decimalFormats[decimalPartLength].format(value) + "\r\n"; |
|
304 |
} |
|
305 |
|
|
306 |
/** |
|
307 |
* Convierte a String un dato del DxfGroup |
|
308 |
* @param code |
|
309 |
* @param value |
|
310 |
* @return String |
|
311 |
*/ |
|
312 |
public static String toString(int code, Object value) { |
|
313 |
if (value instanceof String) { |
|
314 |
return toString(code, (String) value); |
|
315 |
} else if (value instanceof Integer) { |
|
316 |
return toString(code, ((Integer) value).intValue()); |
|
317 |
} else if (value instanceof Double) { |
|
318 |
return toString(code, ((Double) value).floatValue(), 3); |
|
319 |
} else if (value instanceof Double) { |
|
320 |
return toString(code, ((Double) value).doubleValue(), 6); |
|
321 |
} else { |
|
322 |
return toString(code, value.toString()); |
|
323 |
} |
|
324 |
} |
|
325 |
|
|
326 |
/** |
|
327 |
* Convierte a String un dato del DxfGroup |
|
328 |
*/ |
|
329 |
public String toString() { |
|
330 |
return toString(code, data); |
|
331 |
} |
|
332 |
|
|
333 |
/** |
|
334 |
* jmorell: Permite rellenar los datos. �til en la escritura de DXFs. |
|
335 |
* @param data The data to set. |
|
336 |
*/ |
|
337 |
public void setData(Object data) { |
|
338 |
this.data = data; |
|
339 |
} |
|
340 |
|
|
341 |
/** |
|
342 |
* jmorell: Permite rellenar los c�digos. �til en la escritura de DXFs. |
|
343 |
* @param code The code to set. |
|
344 |
*/ |
|
345 |
public void setCode(int code) { |
|
346 |
this.code = code; |
|
347 |
} |
|
348 |
} |
org.gvsig.dxf/tags/org.gvsig.dxf-2.0.76/org.gvsig.dxf.lib/src/main/java/org/gvsig/dxf/io/ZipFileFolder.java | ||
---|---|---|
1 |
/* |
|
2 |
* Cresques Mapping Suite. Graphic Library for constructing mapping applications. |
|
3 |
* |
|
4 |
* Copyright (C) 2004-5. |
|
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
19 |
* |
|
20 |
* For more information, contact: |
|
21 |
* |
|
22 |
* cresques@gmail.com |
|
23 |
*/ |
|
24 |
package org.gvsig.dxf.io; |
|
25 |
|
|
26 |
import java.io.IOException; |
|
27 |
import java.io.InputStream; |
|
28 |
import java.util.Enumeration; |
|
29 |
import java.util.zip.ZipEntry; |
|
30 |
import java.util.zip.ZipFile; |
|
31 |
|
|
32 |
|
|
33 |
/** |
|
34 |
* @author "Luis W. Sevilla" <sevilla_lui@gva.es>* @author administrador |
|
35 |
*/ |
|
36 |
public class ZipFileFolder extends FileFolder { |
|
37 |
String zName = null; |
|
38 |
public ZipFile file = null; |
|
39 |
|
|
40 |
public ZipFileFolder() { |
|
41 |
super(); |
|
42 |
} |
|
43 |
|
|
44 |
/** |
|
45 |
* Constructor. |
|
46 |
* |
|
47 |
* @param fname |
|
48 |
*/ |
|
49 |
public ZipFileFolder(String fName) throws IOException { |
|
50 |
fName = DataSource.normalize(fName); |
|
51 |
|
|
52 |
if (isUrl(fName)) { |
|
53 |
zName = getZName(fName); |
|
54 |
} else { |
|
55 |
zName = fName; |
|
56 |
} |
|
57 |
|
|
58 |
file = new ZipFile(zName); |
|
59 |
} |
|
60 |
|
|
61 |
/** |
|
62 |
* Analiza un nombre de fichero en formato zip://zipname.zip?file.ext |
|
63 |
* @param urlName |
|
64 |
*/ |
|
65 |
public static boolean isUrl(String name) { |
|
66 |
String str = name.substring(0, 3); |
|
67 |
str.toLowerCase(); |
|
68 |
|
|
69 |
if (str.compareTo("zip") == 0) { |
|
70 |
return true; |
|
71 |
} |
|
72 |
|
|
73 |
return false; |
|
74 |
} |
|
75 |
|
|
76 |
private String getZName(String urlName) { |
|
77 |
return urlName.substring(6, urlName.indexOf("?")); |
|
78 |
} |
|
79 |
|
|
80 |
private String getFName(String urlName) { |
|
81 |
return urlName.substring(urlName.indexOf("?") + 1); |
|
82 |
} |
|
83 |
|
|
84 |
public ZipEntry getZipEntry(String fName) throws IOException { |
|
85 |
InputStream is = null; |
|
86 |
|
|
87 |
if (isUrl(fName)) { |
|
88 |
fName = getFName(fName); |
|
89 |
} |
|
90 |
|
|
91 |
return file.getEntry(fName); |
|
92 |
} |
|
93 |
|
|
94 |
public InputStream getInputStream(String fName) throws IOException { |
|
95 |
return file.getInputStream(getZipEntry(fName)); |
|
96 |
} |
|
97 |
|
|
98 |
public InputStream getInputStream(ZipEntry ze) throws IOException { |
|
99 |
return file.getInputStream(ze); |
|
100 |
} |
|
101 |
|
|
102 |
public int count() { |
|
103 |
return file.size(); |
|
104 |
} |
|
105 |
|
|
106 |
public Enumeration entries() { |
|
107 |
return file.entries(); |
|
108 |
} |
|
109 |
} |
org.gvsig.dxf/tags/org.gvsig.dxf-2.0.76/org.gvsig.dxf.lib/src/main/java/org/gvsig/dxf/io/DxfFile.java | ||
---|---|---|
1 |
/* |
|
2 |
* Cresques Mapping Suite. Graphic Library for constructing mapping applications. |
|
3 |
* |
|
4 |
* Copyright (C) 2004-5. |
|
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
19 |
* |
|
20 |
* For more information, contact: |
|
21 |
* |
|
22 |
* cresques@gmail.com |
|
23 |
*/ |
|
24 |
package org.gvsig.dxf.io; |
|
25 |
|
|
26 |
import java.io.BufferedReader; |
|
27 |
import java.io.FileReader; |
|
28 |
import java.io.FileWriter; |
|
29 |
import java.io.IOException; |
|
30 |
import java.io.InputStream; |
|
31 |
import java.io.InputStreamReader; |
|
32 |
import java.io.Reader; |
|
33 |
import java.util.Date; |
|
34 |
import java.util.Hashtable; |
|
35 |
import java.util.Vector; |
|
36 |
|
|
37 |
import org.cresques.cts.ICoordTrans; |
|
38 |
import org.cresques.cts.IProjection; |
|
39 |
import org.cresques.geo.Projected; |
|
40 |
import org.cresques.px.Extent; |
|
41 |
import org.gvsig.dxf.px.IObjList; |
|
42 |
import org.gvsig.dxf.px.dxf.DxfEntityMaker; |
|
43 |
import org.gvsig.dxf.px.dxf.DxfHeaderManager; |
|
44 |
import org.gvsig.dxf.px.dxf.DxfHeaderVariables; |
|
45 |
import org.slf4j.Logger; |
|
46 |
import org.slf4j.LoggerFactory; |
|
47 |
|
|
48 |
/** |
|
49 |
* Clase que representa un fichero en formato DXF. Contiene los interfaces y |
|
50 |
* m�todos necesarios para acceder a la informaci�n almacenada en su |
|
51 |
* interior. |
|
52 |
* |
|
53 |
* @author jmorell |
|
54 |
*/ |
|
55 |
public class DxfFile extends GeoFile { |
|
56 |
|
|
57 |
public static Logger logger = LoggerFactory.getLogger(DxfFile.class); |
|
58 |
|
|
59 |
private boolean cadFlag = true; |
|
60 |
|
|
61 |
long lineNr = 0; |
|
62 |
|
|
63 |
String buf = null; |
|
64 |
|
|
65 |
BufferedReader fi; |
|
66 |
long l = 0; |
|
67 |
int count = 0; |
|
68 |
DxfGroup grp = null; |
|
69 |
|
|
70 |
EntityFactory entityMaker = null; |
|
71 |
VarSettings headerManager; |
|
72 |
private boolean dxf3DFlag; |
|
73 |
|
|
74 |
/** |
|
75 |
* Crea los objetos en el Modelo correspondiente. |
|
76 |
* |
|
77 |
* @author "Luis W. Sevilla" <sevilla_lui@gva.es> |
|
78 |
*/ |
|
79 |
public interface EntityFactory extends Projected { |
|
80 |
|
|
81 |
/** |
|
82 |
* Permite saber si se est�n a�adiendo elementos a un bloque |
|
83 |
* |
|
84 |
* @param booleano que indica si se est�n a�adiendo elementos a un |
|
85 |
* bloque |
|
86 |
*/ |
|
87 |
public void setAddingToBlock(boolean a); |
|
88 |
|
|
89 |
/** |
|
90 |
* Crea una nueva capa partiendo de la informaci�n almacenada en el |
|
91 |
* DXF |
|
92 |
* |
|
93 |
* @param DxfGroupVector con informaci�n para la construcci�n de la |
|
94 |
* nueva capa |
|
95 |
* @throws Exception |
|
96 |
*/ |
|
97 |
public void createLayer(DxfGroupVector v) throws Exception; |
|
98 |
|
|
99 |
/** |
|
100 |
* Crea una nueva polil�nea partiendo de la informaci�n almacenada |
|
101 |
* en el DXF |
|
102 |
* |
|
103 |
* @param DxfGroupVector con informaci�n para la construcci�n de la |
|
104 |
* nueva polil�nea |
|
105 |
* @throws Exception |
|
106 |
*/ |
|
107 |
public void createPolyline(DxfGroupVector v) throws Exception; |
|
108 |
|
|
109 |
/** |
|
110 |
* A�ade un v�rtice a la polil�nea que se est� creando |
|
111 |
* |
|
112 |
* @param DxfGroupVector con la informaci�n necesaria para la |
|
113 |
* adici�n del v�rtice |
|
114 |
* @throws Exception |
|
115 |
*/ |
|
116 |
public void addVertex(DxfGroupVector v) throws Exception; |
|
117 |
|
|
118 |
/** |
|
119 |
* Fin de secuencia |
|
120 |
* |
|
121 |
* @throws Exception |
|
122 |
*/ |
|
123 |
public void endSeq() throws Exception; |
|
124 |
|
|
125 |
/** |
|
126 |
* Crea una nueva LwPolyline partiendo de la informaci�n almacenada en |
|
127 |
* el DXF |
|
128 |
* |
|
129 |
* @param DxfGroupVector con informaci�n para la construcci�n de la |
|
130 |
* nueva polil�nea |
|
131 |
* @throws Exception |
|
132 |
*/ |
|
133 |
public void createLwPolyline(DxfGroupVector v) throws Exception; |
|
134 |
|
|
135 |
/** |
|
136 |
* Crea una nueva l�nea partiendo de la informaci�n almacenada en el |
|
137 |
* DXF |
|
138 |
* |
|
139 |
* @param DxfGroupVector con informaci�n para la construcci�n de la |
|
140 |
* nueva l�nea |
|
141 |
* @throws Exception |
|
142 |
*/ |
|
143 |
public void createLine(DxfGroupVector v) throws Exception; |
|
144 |
|
|
145 |
/** |
|
146 |
* Crea un nuevo texto partiendo de la informaci�n almacenada en el |
|
147 |
* DXF |
|
148 |
* |
|
149 |
* @param DxfGroupVector con informaci�n para la construcci�n del |
|
150 |
* nuevo texto |
|
151 |
* @throws Exception |
|
152 |
*/ |
|
153 |
public void createText(DxfGroupVector v) throws Exception; |
|
154 |
|
|
155 |
/** |
|
156 |
* Crea un nuevo MText partiendo de la informaci�n almacenada en el |
|
157 |
* DXF |
|
158 |
* |
|
159 |
* @param DxfGroupVector con informaci�n para la construcci�n del |
|
160 |
* nuevo MText |
|
161 |
* @throws Exception |
|
162 |
*/ |
|
163 |
public void createMText(DxfGroupVector v) throws Exception; |
|
164 |
|
|
165 |
/** |
|
166 |
* Crea un nuevo punto partiendo de la informaci�n almacenada en el |
|
167 |
* DXF |
|
168 |
* |
|
169 |
* @param DxfGroupVector con informaci�n para la construcci�n del |
|
170 |
* nuevo punto |
|
171 |
* @throws Exception |
|
172 |
*/ |
|
173 |
public void createPoint(DxfGroupVector v) throws Exception; |
|
174 |
|
|
175 |
/** |
|
176 |
* Crea un nuevo c�rculo partiendo de la informaci�n almacenada en |
|
177 |
* el DXF |
|
178 |
* |
|
179 |
* @param DxfGroupVector con informaci�n para la construcci�n del |
|
180 |
* nuevo c�rculo |
|
181 |
* @throws Exception |
|
182 |
*/ |
|
183 |
public void createCircle(DxfGroupVector v) throws Exception; |
|
184 |
|
|
185 |
/** |
|
186 |
* Crea una nueva elipse partiendo de la informaci�n almacenada en el |
|
187 |
* DXF |
|
188 |
* |
|
189 |
* @param DxfGroupVector con informaci�n para la construcci�n de la |
|
190 |
* nueva elipse |
|
191 |
* @throws Exception |
|
192 |
*/ |
|
193 |
public void createEllipse(DxfGroupVector v) throws Exception; |
|
194 |
|
|
195 |
/** |
|
196 |
* Crea un nuevo arco partiendo de la informaci�n almacenada en el DXF |
|
197 |
* |
|
198 |
* @param DxfGroupVector con informaci�n para la construcci�n del |
|
199 |
* nuevo arco |
|
200 |
* @throws Exception |
|
201 |
*/ |
|
202 |
public void createArc(DxfGroupVector v) throws Exception; |
|
203 |
|
|
204 |
/** |
|
205 |
* Crea un nuevo punto de inserci�n partiendo de la informaci�n |
|
206 |
* almacenada en el DXF |
|
207 |
* |
|
208 |
* @param DxfGroupVector con informaci�n para la construcci�n del |
|
209 |
* nuevo punto de inserci�n |
|
210 |
* @throws Exception |
|
211 |
*/ |
|
212 |
public void createInsert(DxfGroupVector v) throws Exception; |
|
213 |
|
|
214 |
/** |
|
215 |
* Crea un nuevo s�lido 2D partiendo de la informaci�n almacenada en |
|
216 |
* el DXF |
|
217 |
* |
|
218 |
* @param DxfGroupVector con informaci�n para la construcci�n del |
|
219 |
* nuevo s�lido |
|
220 |
* @throws Exception |
|
221 |
*/ |
|
222 |
public void createSolid(DxfGroupVector v) throws Exception; |
|
223 |
|
|
224 |
/** |
|
225 |
* Crea un nuevo Spline partiendo de la informaci�n almacenada en el |
|
226 |
* DXF |
|
227 |
* |
|
228 |
* @param DxfGroupVector con informaci�n para la construcci�n del |
|
229 |
* nuevo Spline |
|
230 |
* @throws Exception |
|
231 |
*/ |
|
232 |
public void createSpline(DxfGroupVector v) throws Exception; |
|
233 |
|
|
234 |
/** |
|
235 |
* Construye la definici�n de un nuevo atributo partiendo de la |
|
236 |
* informaci�n almacenada en el DXF |
|
237 |
* |
|
238 |
* @param DxfGroupVector con informaci�n para la construcci�n de la |
|
239 |
* definici�n del nuevo atributo |
|
240 |
* @throws Exception |
|
241 |
*/ |
|
242 |
public void createAttdef(DxfGroupVector v) throws Exception; |
|
243 |
|
|
244 |
/** |
|
245 |
* Crea un nuevo atributo partiendo de la informaci�n almacenada en el |
|
246 |
* DXF |
|
247 |
* |
|
248 |
* @param DxfGroupVector con informaci�n para la creaci�n del nuevo |
|
249 |
* atributo |
|
250 |
* @throws Exception |
|
251 |
*/ |
|
252 |
public void createAttrib(DxfGroupVector v) throws Exception; |
|
253 |
|
|
254 |
/** |
|
255 |
* Crea un bloque |
|
256 |
* |
|
257 |
* @param DxfGroupVector con informaci�n para la creaci�n del nuevo |
|
258 |
* elemento |
|
259 |
* @throws Exception |
|
260 |
*/ |
|
261 |
public void createBlock(DxfGroupVector v) throws Exception; |
|
262 |
|
|
263 |
/** |
|
264 |
* Fin de la definici�n de un bloqe |
|
265 |
* |
|
266 |
* @param DxfGroupVector con informaci�n referente al final de un |
|
267 |
* bloque |
|
268 |
* @throws Exception |
|
269 |
*/ |
|
270 |
public void endBlk(DxfGroupVector v) throws Exception; |
|
271 |
|
|
272 |
/** |
|
273 |
* Gestiona los bloques que no se han tratado en la primera vuelta |
|
274 |
*/ |
|
275 |
void testBlocks(); |
|
276 |
|
|
277 |
/** |
|
278 |
* Devuelve el extent |
|
279 |
* |
|
280 |
* @return el extent |
|
281 |
*/ |
|
282 |
public Extent getExtent(); |
|
283 |
|
|
284 |
/** |
|
285 |
* Devuelve la lista de bloques |
|
286 |
* |
|
287 |
* @return la lista de bloques |
|
288 |
*/ |
|
289 |
public Vector getBlkList(); |
|
290 |
|
|
291 |
/** |
|
292 |
* Permite la gesti�n de los atributos almacenados en unn DXF |
|
293 |
* |
|
294 |
* @return un Vector con la lista de atributos |
|
295 |
*/ |
|
296 |
public Vector getAttributes(); |
|
297 |
|
|
298 |
/** |
|
299 |
* Borra los atributos repetidos |
|
300 |
*/ |
|
301 |
public void depureAttributes(); |
|
302 |
|
|
303 |
/** |
|
304 |
* Devuelve los objetos almacenados en el DXF |
|
305 |
* |
|
306 |
* @return IObjList con los objetos procedentes del DXF |
|
307 |
*/ |
|
308 |
public IObjList getObjects(); |
|
309 |
|
|
310 |
/** |
|
311 |
* Permite saber si se trata de un fichero DXF en 2D o en 3D |
|
312 |
* |
|
313 |
* @return booleano que indica si se trata de un fichero DXF 3D |
|
314 |
*/ |
|
315 |
public boolean isDxf3DFile(); |
|
316 |
}; |
|
317 |
|
|
318 |
/** |
|
319 |
* Establece el estado de las variables propias de un DXF que est�n |
|
320 |
* definidas en la secci�n HEADER. Por ejemplo, la versi�n del DXF. |
|
321 |
* |
|
322 |
* @author jmorell (jose.morell@gmail.com) |
|
323 |
* @version 15-dic-2004 |
|
324 |
*/ |
|
325 |
public interface VarSettings { |
|
326 |
|
|
327 |
/** |
|
328 |
* Establece la versi�n de Autocad en la que fue generado el DXF. |
|
329 |
* |
|
330 |
* @param informaci�n de base |
|
331 |
* @throws Exception |
|
332 |
*/ |
|
333 |
public void setAcadVersion(DxfGroupVector v) throws Exception; |
|
334 |
|
|
335 |
/** |
|
336 |
* Devuelve la versi�n de Autocad en la que fue generado el DXF. |
|
337 |
* |
|
338 |
* @return |
|
339 |
*/ |
|
340 |
public String getAcadVersion(); |
|
341 |
|
|
342 |
/** |
|
343 |
* Devuelve el estado de las variables propias de un DXF |
|
344 |
* |
|
345 |
* @return |
|
346 |
*/ |
|
347 |
public DxfHeaderVariables getDxfHeaderVars(); |
|
348 |
|
|
349 |
public boolean isWritedDxf3D(); |
|
350 |
|
|
351 |
public void loadMinZFromHeader(double d); |
|
352 |
|
|
353 |
public void loadMaxZFromHeader(double d); |
|
354 |
}; |
|
355 |
|
|
356 |
/** |
|
357 |
* Constructor de la clase |
|
358 |
* |
|
359 |
* @param proj, la proyecci�n cartogr�fica |
|
360 |
* @param name, el path absoluto hasta el fichero DXF |
|
361 |
* @param maker, el interface que permite la construcci�n de las entidades |
|
362 |
* procedentes del DXF |
|
363 |
*/ |
|
364 |
public DxfFile(IProjection proj, String name, EntityFactory maker) { |
|
365 |
super(proj, name); |
|
366 |
entityMaker = maker; |
|
367 |
headerManager = new DxfHeaderManager(); |
|
368 |
} |
|
369 |
|
|
370 |
/** |
|
371 |
* Constructor de la clase que adem�s incorpora la capacidad de leer una |
|
372 |
* porci�n del HEADER |
|
373 |
* |
|
374 |
* @param proj, la proyecci�n cartogr�fica |
|
375 |
* @param name, el path absoluto hasta el fichero DXF |
|
376 |
* @param maker, el interface que permite la construcci�n de las entidades |
|
377 |
* procedentes del DXF |
|
378 |
* @param dxfVars, el interface que permite la lectura del HEADER de un DXF |
|
379 |
*/ |
|
380 |
public DxfFile(IProjection proj, String name, EntityFactory maker, VarSettings dxfVars) { |
|
381 |
super(proj, name); |
|
382 |
entityMaker = maker; |
|
383 |
headerManager = dxfVars; |
|
384 |
} |
|
385 |
|
|
386 |
/** |
|
387 |
* Carga un fichero en formato DXF |
|
388 |
* |
|
389 |
* @throws Exception |
|
390 |
*/ |
|
391 |
public GeoFile load() throws Exception { |
|
392 |
logger.debug("Dxf: Cargando " + name + " ..."); |
|
393 |
if (ZipFileFolder.isUrl(name)) { |
|
394 |
ZipFileFolder zFolder = new ZipFileFolder(name); |
|
395 |
InputStream is = zFolder.getInputStream(name); |
|
396 |
return load(new InputStreamReader(is)); |
|
397 |
} else { |
|
398 |
return load(new FileReader(name)); |
|
399 |
} |
|
400 |
|
|
401 |
} |
|
402 |
|
|
403 |
/** |
|
404 |
* Carga un fichero en formato DXF tomando un Reader como par�metro |
|
405 |
* |
|
406 |
* @param fr, Reader que se le pasa como par�metro |
|
407 |
* @return devuelve un objeto GeoFile, padre de DxfFile |
|
408 |
* @throws Exception |
|
409 |
* @throws Exception |
|
410 |
*/ |
|
411 |
public GeoFile load(Reader fr) throws Exception { |
|
412 |
logger.debug("Dxf: Cargando '" + name + "' ..."); |
|
413 |
fi = new BufferedReader(fr); |
|
414 |
while ((grp = readGrp()) != null) { |
|
415 |
l += 2; |
|
416 |
|
|
417 |
if (grp.equals(0, "EOF")) { |
|
418 |
break; |
|
419 |
} |
|
420 |
if (grp.equals(0, "SECTION")) { |
|
421 |
readSection(); |
|
422 |
} |
|
423 |
} |
|
424 |
fi.close(); |
|
425 |
extent.add(entityMaker.getExtent()); |
|
426 |
logger.debug("Dxf: '" + name + "' cargado. (" + l + " l�neas)."); |
|
427 |
this.lineNr = l; |
|
428 |
return this; |
|
429 |
} |
|
430 |
|
|
431 |
/** |
|
432 |
* El fichero DXF se divide en grupos. Este m�todo permite leer cada grupo |
|
433 |
* individualmente |
|
434 |
* |
|
435 |
* @return devuelve la informaci�n del DXF en forma de objetos de la clase |
|
436 |
* DxfGroup |
|
437 |
* @throws NumberFormatException |
|
438 |
* @throws IOException |
|
439 |
*/ |
|
440 |
private DxfGroup readGrp() throws NumberFormatException, IOException { |
|
441 |
DxfGroup g = DxfGroup.read(fi); |
|
442 |
if (g != null) { |
|
443 |
l += 2; |
|
444 |
} |
|
445 |
/*if (g.code == 8) |
|
446 |
if (((String) g.data).length() < 1) { |
|
447 |
logger.error("a que un layer no puede ser ''?"); |
|
448 |
System.exit(1); |
|
449 |
}*/ |
|
450 |
return g; |
|
451 |
} |
|
452 |
|
|
453 |
/** |
|
454 |
* El fichero DXF se divide en varias secciones. Este m�todo se encarga de |
Also available in: Unified diff