Revision 33821

View differences:

tags/v2_0_0_Build_2020/extensions/extDwg/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"
4
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
5
                      http://maven.apache.org/xsd/maven-4.0.0.xsd">
6
                      
7
	<modelVersion>4.0.0</modelVersion>
8
	<groupId>org.gvsig</groupId>
9
	<artifactId>org.gvsig.dwg.extension</artifactId>
10
	<packaging>jar</packaging>
11
	<version>2.0-SNAPSHOT</version>
12
	<name>extDwg</name>
13
	<url>http://maven.apache.org</url>
14
	<parent>
15
		<groupId>org.gvsig</groupId>
16
		<artifactId>gvsig-base-extension-pom</artifactId>
17
		<version>2.0-SNAPSHOT</version>
18
	</parent>	
19
	<distributionManagement>
20
		<site>
21
			<id>gvsig-repository</id>
22
			<url>${site-repository}/</url>
23
		</site>
24
	</distributionManagement>
25

  
26
	<dependencies>
27
		<dependency>
28
			<groupId>org.gvsig</groupId>
29
			<artifactId>org.gvsig.fmap.dal</artifactId>
30
			<version>2.0-SNAPSHOT</version>
31
		</dependency>
32
		<dependency>
33
			<groupId>org.gvsig</groupId>
34
			<artifactId>org.gvsig.fmap.dal</artifactId>
35
			<version>2.0-SNAPSHOT</version>
36
			<classifier>spi</classifier>
37
		</dependency>				
38
		<dependency>
39
			<groupId>org.gvsig</groupId>
40
			<artifactId>org.gvsig.fmap.dal.file</artifactId>
41
			<version>2.0-SNAPSHOT</version>
42
		</dependency>
43
		<dependency>
44
			<groupId>org.gvsig</groupId>
45
			<artifactId>org.gvsig.symbology</artifactId>
46
			<version>2.0-SNAPSHOT</version>
47
		</dependency>		
48
		<dependency>
49
			<groupId>org.gvsig</groupId>
50
			<artifactId>org.gvsig.dwg</artifactId>
51
			<version>2.0-SNAPSHOT</version>
52
		</dependency>
53
	    <dependency>
54
	      <groupId>org.gvsig</groupId>
55
	      <artifactId>org.gvsig.app</artifactId>
56
	      <version>2.0-SNAPSHOT</version>
57
	    </dependency>
58
	    <dependency>
59
			<groupId>org.gvsig</groupId>
60
			<artifactId>org.gvsig.fmap.mapcontext</artifactId>
61
			<version>2.0-SNAPSHOT</version>
62
		</dependency>
63
	    <!-- Test scope -->
64
		<dependency>
65
			<groupId>org.gvsig</groupId>
66
			<artifactId>org.gvsig.fmap.dal</artifactId>
67
			<version>2.0-SNAPSHOT</version>
68
			<classifier>impl</classifier>
69
			<scope>test</scope>
70
		</dependency>	
71
		<dependency>
72
			<groupId>org.gvsig</groupId>
73
			<artifactId>org.gvsig.fmap.dal</artifactId>
74
			<version>2.0-SNAPSHOT</version>
75
			<classifier>tests</classifier>
76
			<scope>test</scope>
77
		</dependency>
78
		<dependency>
79
			<groupId>org.gvsig</groupId>
80
			<artifactId>org.gvsig.fmap.dal.index.spatial</artifactId>
81
			<version>2.0-SNAPSHOT</version>
82
			<classifier>jts</classifier>
83
			<scope>test</scope>
84
		</dependency>
85
		<dependency>
86
			<groupId>org.gvsig</groupId>
87
			<artifactId>org.gvsig.fmap.geometry</artifactId>
88
			<version>2.0-SNAPSHOT</version>
89
			<classifier>impl</classifier>
90
			<scope>test</scope>
91
		</dependency>
92
		<dependency>
93
			<groupId>org.gvsig</groupId>
94
			<artifactId>org.gvsig.projection</artifactId>
95
			<version>2.0-SNAPSHOT</version>
96
			<classifier>cresques-impl</classifier>
97
			<scope>test</scope>
98
		</dependency>
99
		<dependency>
100
			<groupId>org.gvsig</groupId>
101
			<artifactId>org.gvsig.fmap.mapcontext</artifactId>
102
			<version>2.0-SNAPSHOT</version>
103
			<classifier>operation</classifier>
104
			<scope>test</scope>
105
		</dependency>
106
		<dependency>
107
			<groupId>org.gvsig</groupId>
108
			<artifactId>org.gvsig.tools.lib</artifactId>
109
			<classifier>tests</classifier>
110
			<scope>test</scope>
111
		</dependency>
112
	</dependencies>
113
	<properties>
114
		<build-dir>${basedir}/../build</build-dir>
115
	</properties>
116
	<build>
117
		<sourceDirectory>src</sourceDirectory>
118
		<testSourceDirectory>src-test</testSourceDirectory>
119
        <testResources>
120
                <testResource>
121
                        <directory>src-test</directory>
122
                </testResource>
123
        </testResources>
124
        <resources>
125
            <resource>
126
                <directory>resources</directory>
127
            </resource>
128
        </resources>
129
        <plugins>
130
            <!-- TODO: MAKE TESTS WORK AND REMOVE THIS OPTION -->
131
            <plugin>
132
                <groupId>org.apache.maven.plugins</groupId>
133
                <artifactId>maven-surefire-plugin</artifactId>
134
                <configuration>
135
                    <skipTests>true</skipTests>
136
                </configuration>
137
            </plugin>       
138
        </plugins>
139
	</build>
140
</project>
0 141

  
tags/v2_0_0_Build_2020/extensions/extDwg/resources/org/gvsig/dwg/fmap/dal/store/dwg/DWGMetadata.xml
1
<?xml version="1.0"?>
2
<!--
3
Definitions of metadata fields of a DWG file.  
4
 -->
5
<definitions>
6
  <version>1.0.0</version>
7
  <classes>
8
    
9
    <class name="DWG" namespace="Metadata">
10
      <extends>
11
      	<class namespace="Metadata" name="SpatialProvider"/>
12
      </extends>
13
      <description>Metadata of a DWG store</description>
14
      <fields>
15
      </fields>
16
    </class>
17

  
18
  </classes>
19
</definitions>  
tags/v2_0_0_Build_2020/extensions/extDwg/resources/org/gvsig/dwg/fmap/dal/store/dwg/DWGParameters.xml
1
<?xml version= "1.0 "?>
2
<definitions>
3
  <version>1.0.0</version>
4
  <classes>
5
    <class name="DWGStoreParameters">
6
      <extends>
7
      	<class namespace="dal" name="ProviderParameters"/>
8
      </extends>
9
      <description>Store the parameters need to open a dwg file</description>
10
      <fields>
11
        <field name="file" type="file" mandatory="true">
12
          <description>dwg file</description>
13
        </field>
14
        <field name="CRS" type="crs" mandatory="true">
15
          <description>The coordinate reference system used in this dwg file</description>
16
        </field>
17
      </fields>
18
    </class>
19
  </classes>
20
</definitions>  
tags/v2_0_0_Build_2020/extensions/extDwg/resources/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.dwg.fmap.dal.store.dwg.DWGLibrary
2
org.gvsig.dwg.fmap.dal.store.dwg.legend.DWGLegendLibrary
tags/v2_0_0_Build_2020/extensions/extDwg/distribution/distribution.xml
1
<assembly>
2
	<id>distribution</id>
3
	<formats>
4
		<format>dir</format>
5
	</formats>
6
	<fileSets>
7
	<!-- Extructure for the extension -->
8
		<fileSet>
9
			<directory>config</directory>
10
			<outputDirectory>${extension.install.dir.name}
11
			</outputDirectory>
12
		</fileSet>
13
		<fileSet>
14
			<directory>images</directory>
15
			<outputDirectory>/${extension.install.dir.name}/images
16
			</outputDirectory>
17
		</fileSet>
18
	</fileSets>
19
    <files>
20
        <file>
21
            <source>package.info</source>
22
            <outputDirectory>${extension.install.dir.name}
23
            </outputDirectory>
24
        </file>
25
    </files>
26
	<!--
27
		***********************************************************************
28
	-->
29
  <!-- *													   *-->
30
	<!--
31
		***********************************************************************
32
	-->
33
	<dependencySets>
34
		<dependencySet>
35
			<outputDirectory>${extension.install.dir.name}/${library-dir}
36
			</outputDirectory>
37
			<includes>
38
				<include>org.gvsig:org.gvsig.dwg</include>
39
				<include>org.gvsig:org.gvsig.dwg.extension</include>
40
			</includes>
41
		</dependencySet>
42
	</dependencySets>
43
</assembly>
0 44

  
tags/v2_0_0_Build_2020/extensions/extDwg/buildNumber.properties
1
#maven.buildNumber.plugin properties file
2
#Tue Oct 26 12:07:05 CEST 2010
3
buildNumber=2020
tags/v2_0_0_Build_2020/extensions/extDwg/src-test/org/gvsig/dwg/fmap/dal/store/dwg/TestDWG.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. S.A.   {{Task}}
26
*/
27

  
28
package org.gvsig.dwg.fmap.dal.store.dwg;
29

  
30
import java.io.File;
31

  
32
import org.gvsig.fmap.dal.DataStoreParameters;
33
import org.gvsig.fmap.dal.exception.DataException;
34
import org.gvsig.fmap.dal.feature.BaseTestFeatureStore;
35
import org.gvsig.fmap.dal.feature.FeatureStore;
36

  
37
public class TestDWG extends BaseTestFeatureStore {
38

  
39
	protected boolean testDXFInitialized = false;
40

  
41
	public static File file_prueba = new File(TestDWG.class.getResource(
42
			"data/V2000.dwg").getFile());
43

  
44
	/*
45
	 * (non-Javadoc)
46
	 *
47
	 * @see
48
	 * org.gvsig.fmap.dal.feature.BaseTestFeatureStore#getDefaultDataStoreParameters
49
	 * ()
50
	 */
51
	public DataStoreParameters getDefaultDataStoreParameters()
52
			throws DataException {
53
		DWGStoreParameters dwgParameters = null;
54

  
55
		dwgParameters = (DWGStoreParameters) dataManager
56
				.createStoreParameters(DWGStoreProvider.NAME);
57

  
58
		dwgParameters.setFile(file_prueba);
59
		dwgParameters.setCRS("EPSG:23030");
60
		return dwgParameters;
61
	}
62

  
63
	/*
64
	 * (non-Javadoc)
65
	 *
66
	 * @see org.gvsig.fmap.dal.feature.BaseTestFeatureStore#hasExplorer()
67
	 */
68
	public boolean hasExplorer() {
69
		// TODO Auto-generated method stub
70
		return false;
71
	}
72

  
73
	public boolean usesResources() {
74
		return true;
75
	}
76

  
77

  
78
	public void testLegendAndLabeling() throws Exception {
79
		DataStoreParameters params = getDefaultDataStoreParameters();
80
		FeatureStore store = (FeatureStore) dataManager.openStore(params
81
				.getDataStoreName(), params);
82

  
83
		assertNotNull(store.invokeDynMethod("getLegend", null));
84
		assertNotNull(store.invokeDynMethod("getLabeling", null));
85
		store.dispose();
86
	}
87
}
0 88

  
tags/v2_0_0_Build_2020/extensions/extDwg/src-test/org/gvsig/dwg/fmap/dal/store/dwg/TestDWG2004.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
* 2009 IVER T.I   {{Task}}
26
*/
27

  
28
package org.gvsig.dwg.fmap.dal.store.dwg;
29

  
30
import java.io.File;
31

  
32
public class TestDWG2004 extends TestDWG {
33
	public static File file_prueba = new File(TestDWG.class.getResource(
34
			"data/V2004.dwg").getFile());
35
}
0 36

  
tags/v2_0_0_Build_2020/extensions/extDwg/config/config.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<plugin-config>
3
	<libraries library-dir="lib">
4
	</libraries>
5
	<depends plugin-name="org.gvsig.app"/>
6
		<resourceBundle name="text"/>
7
	<extensions>
8
		<extension class-name="org.gvsig.dwg.DWGRegisterExtension"
9
			description="DWG Driver"
10
			active="true">
11
		</extension>
12

  
13
	</extensions>
14
</plugin-config>
0 15

  
tags/v2_0_0_Build_2020/extensions/extDwg/package.info
1
#
2
#Tue Oct 26 12:07:05 CEST 2010
3
state=devel
4
name=extDwg
5
official=true
6
code=org.gvsig.dwg.extension
7
operating-system=all
8
architecture=all
9
java-version=j1_5
10
gvSIG-version=2.0.0
11
version=2.0-SNAPSHOT
12
type=plugin
13
build=2020
14
description=Base POM for all GvSIG extension projects. This pom knows\n\t\thow to build and made an extension for GvSIG. The property\n\t\t"build-dir" must be set up correctly.
tags/v2_0_0_Build_2020/extensions/extDwg/src/org/gvsig/dwg/DWGRegisterExtension.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
package org.gvsig.dwg;
23

  
24
import org.gvsig.andami.plugins.Extension;
25
import org.gvsig.dwg.fmap.dal.store.dwg.DWGLibrary;
26

  
27
/**
28
 * Dummy DWG extension, as all the registration happens in the
29
 * {@link DWGLibrary}.
30
 * 
31
 * @author gvSIG Team
32
 */
33
public class DWGRegisterExtension extends Extension {
34

  
35
	public void execute(String actionCommand) {
36
		// Nothing to do
37
	}
38

  
39
	public void initialize() {
40
		// Nothing to do
41
	}
42

  
43
	public void postInitialize() {
44
		super.postInitialize();
45
		// Nothing to do
46
	}
47

  
48
	public boolean isEnabled() {
49
		// Nothing to do
50
		return false;
51
	}
52

  
53
	public boolean isVisible() {
54
		// Nothing to do
55
		return false;
56
	}
57

  
58
}
0 59

  
tags/v2_0_0_Build_2020/extensions/extDwg/src/org/gvsig/dwg/fmap/dal/store/dwg/DWGFilesystemServerProvider.java
1
package org.gvsig.dwg.fmap.dal.store.dwg;
2

  
3
import java.io.File;
4

  
5
import org.gvsig.fmap.dal.DALLocator;
6
import org.gvsig.fmap.dal.DataManager;
7
import org.gvsig.fmap.dal.DataStoreParameters;
8
import org.gvsig.fmap.dal.NewDataStoreParameters;
9
import org.gvsig.fmap.dal.exception.CreateException;
10
import org.gvsig.fmap.dal.exception.DataException;
11
import org.gvsig.fmap.dal.exception.FileNotFoundException;
12
import org.gvsig.fmap.dal.exception.RemoveException;
13
import org.gvsig.fmap.dal.feature.NewFeatureStoreParameters;
14
import org.gvsig.fmap.dal.resource.spi.ResourceConsumer;
15
import org.gvsig.fmap.dal.resource.spi.ResourceProvider;
16
import org.gvsig.fmap.dal.serverexplorer.filesystem.impl.AbstractFilesystemServerExplorerProvider;
17
import org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProvider;
18
import org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProviderServices;
19

  
20
public class DWGFilesystemServerProvider extends AbstractFilesystemServerExplorerProvider 
21
	implements FilesystemServerExplorerProvider, ResourceConsumer {
22

  
23
	private FilesystemServerExplorerProviderServices serverExplorer;
24

  
25
	public String getDataStoreProviderName() {
26
		return DWGStoreProvider.NAME;
27
	}
28

  
29
	public boolean accept(File pathname) {
30
		return (pathname.getName().toLowerCase().endsWith(".dwg"));
31
	}
32

  
33
	public String getDescription() {
34
		return DWGStoreProvider.DESCRIPTION;
35
	}
36

  
37
	public DataStoreParameters getParameters(File file) throws DataException {
38
		DataManager manager = DALLocator.getDataManager();
39
		DWGStoreParameters params = (DWGStoreParameters) manager
40
				.createStoreParameters(this
41
				.getDataStoreProviderName());
42
		params.setFileName(file.getPath());
43
		return params;
44
	}
45

  
46
	public boolean canCreate() {
47
		return true;
48
	}
49

  
50
	public boolean canCreate(NewDataStoreParameters parameters) {
51
		if (!(parameters instanceof DWGStoreParameters)) {
52
			throw new IllegalArgumentException(); // FIXME ???
53
		}
54
		DWGStoreParameters dwgParams = (DWGStoreParameters) parameters;
55
		// TODO comporbar si el ftype es correcto (para este formato es fijo)
56
		File file = new File(dwgParams.getFileName());
57

  
58
		if (dwgParams.getCRS() == null) {
59
			return false;
60
		}
61
		// TODO comprobamos extension del fichero ??
62
		if (file.exists()) {
63
			return file.canWrite();
64
		} else {
65
			return file.getParentFile().canWrite();
66
		}
67
	}
68

  
69
	public void create(NewDataStoreParameters parameters, boolean overwrite)
70
			throws CreateException {
71
		// FIXME Exception
72
		throw new UnsupportedOperationException();
73
	}
74

  
75
	public NewDataStoreParameters getCreateParameters() throws DataException {
76
		return (NewFeatureStoreParameters) DALLocator.getDataManager()
77
				.createStoreParameters(this.getDataStoreProviderName());
78
	}
79

  
80
	public void initialize(
81
			FilesystemServerExplorerProviderServices serverExplorer) {
82
		this.serverExplorer = serverExplorer;
83
	}
84

  
85
	public void remove(DataStoreParameters parameters) throws RemoveException {
86
		File file = new File(((DWGStoreParameters) parameters).getFileName());
87
		if (!file.exists()) {
88
			throw new RemoveException(this.getDataStoreProviderName(),
89
					new FileNotFoundException(file));
90
		}
91
		if (!file.delete()) {
92
			// FIXME throws ???
93
		}
94

  
95
	}
96

  
97
	public boolean closeResourceRequested(ResourceProvider resource) {
98
		// while it is using a resource anyone can't close it
99
		return false;
100
	}
101

  
102
	/*
103
	 * (non-Javadoc)
104
	 *
105
	 * @see
106
	 * org.gvsig.fmap.dal.resource.spi.ResourceConsumer#resourceChanged(org.
107
	 * gvsig.fmap.dal.resource.spi.ResourceProvider)
108
	 */
109
	public void resourceChanged(ResourceProvider resource) {
110
		//Do nothing
111

  
112
	}
113

  
114

  
115
}
0 116

  
tags/v2_0_0_Build_2020/extensions/extDwg/src/org/gvsig/dwg/fmap/dal/store/dwg/DWGStoreProvider.java
1
package org.gvsig.dwg.fmap.dal.store.dwg;
2

  
3
import java.io.File;
4
import java.io.IOException;
5
import java.util.ArrayList;
6
import java.util.HashMap;
7
import java.util.Iterator;
8
import java.util.List;
9
import java.util.Map;
10

  
11
import org.cresques.cts.IProjection;
12
import org.gvsig.dwg.lib.DwgFile;
13
import org.gvsig.dwg.lib.DwgObject;
14
import org.gvsig.dwg.lib.DwgVersionNotSupportedException;
15
import org.gvsig.dwg.lib.IDwg2FMap;
16
import org.gvsig.dwg.lib.IDwg3DTestable;
17
import org.gvsig.dwg.lib.objects.DwgMText;
18
import org.gvsig.dwg.lib.objects.DwgText;
19
import org.gvsig.fmap.dal.DALLocator;
20
import org.gvsig.fmap.dal.DataManager;
21
import org.gvsig.fmap.dal.DataServerExplorer;
22
import org.gvsig.fmap.dal.DataStoreNotification;
23
import org.gvsig.fmap.dal.DataTypes;
24
import org.gvsig.fmap.dal.FileHelper;
25
import org.gvsig.fmap.dal.exception.DataException;
26
import org.gvsig.fmap.dal.exception.InitializeException;
27
import org.gvsig.fmap.dal.exception.OpenException;
28
import org.gvsig.fmap.dal.exception.ReadException;
29
import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
30
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor;
31
import org.gvsig.fmap.dal.feature.EditableFeatureType;
32
import org.gvsig.fmap.dal.feature.FeatureType;
33
import org.gvsig.fmap.dal.feature.exception.CreateGeometryException;
34
import org.gvsig.fmap.dal.feature.exception.PerformEditingException;
35
import org.gvsig.fmap.dal.feature.spi.FeatureProvider;
36
import org.gvsig.fmap.dal.feature.spi.FeatureStoreProviderServices;
37
import org.gvsig.fmap.dal.feature.spi.memory.AbstractMemoryStoreProvider;
38
import org.gvsig.fmap.dal.resource.ResourceAction;
39
import org.gvsig.fmap.dal.resource.exception.AccessResourceException;
40
import org.gvsig.fmap.dal.resource.file.FileResource;
41
import org.gvsig.fmap.dal.resource.spi.ResourceConsumer;
42
import org.gvsig.fmap.dal.resource.spi.ResourceProvider;
43
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorer;
44
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorerParameters;
45
import org.gvsig.fmap.dal.spi.DataStoreProviderServices;
46
import org.gvsig.fmap.geom.Geometry;
47
import org.gvsig.fmap.geom.GeometryLocator;
48
import org.gvsig.fmap.geom.GeometryManager;
49
import org.gvsig.fmap.geom.Geometry.SUBTYPES;
50
import org.gvsig.fmap.geom.exception.CreateEnvelopeException;
51
import org.gvsig.fmap.geom.primitive.Envelope;
52
import org.gvsig.fmap.geom.primitive.Point;
53
import org.gvsig.tools.dynobject.exception.DynMethodException;
54
import org.gvsig.tools.exception.NotYetImplemented;
55
import org.gvsig.tools.persistence.PersistentState;
56
import org.gvsig.tools.persistence.exception.PersistenceException;
57
import org.slf4j.Logger;
58
import org.slf4j.LoggerFactory;
59

  
60
public class DWGStoreProvider extends AbstractMemoryStoreProvider implements
61
		ResourceConsumer {
62
	private static final Logger logger = LoggerFactory.getLogger(DWGStoreProvider.class);
63

  
64
	public static final String NAME = "DWG";
65
	public static final String DESCRIPTION = "DWG file";
66
	public static final String METADATA_DEFINITION_NAME = NAME;
67

  
68
	public static final String NAME_FIELD_ID = "ID";
69
	public static final String NAME_FIELD_GEOMETRY = "Geometry";
70
	public static final String NAME_FIELD_ENTITY = "Entity";
71
	public static final String NAME_FIELD_LAYER = "Layer";
72
	public static final String NAME_FIELD_COLOR = "Color";
73
	public static final String NAME_FIELD_ELEVATION = "Elevation";
74
	public static final String NAME_FIELD_THICKNESS = "Thickness";
75
	public static final String NAME_FIELD_TEXT = "Text";
76
	public static final String NAME_FIELD_HEIGHTTEXT = "HeightText";
77
	public static final String NAME_FIELD_ROTATIONTEXT = "Rotation";
78

  
79
	private int ID_FIELD_ID = 0;
80
	private int ID_FIELD_GEOMETRY = 1;
81
	private int ID_FIELD_ENTITY = 2;
82
	private int ID_FIELD_LAYER = 3;
83
	private int ID_FIELD_COLOR = 4;
84
	private int ID_FIELD_ELEVATION = 5;
85
	private int ID_FIELD_THICKNESS = 6;
86
	private int ID_FIELD_TEXT = 7;
87
	private int ID_FIELD_HEIGHTTEXT = 8;
88
	private int ID_FIELD_ROTATIONTEXT = 9;
89

  
90
	private IProjection projection;
91
	private ResourceProvider resource;
92
	private LegendBuilder legendBuilder;
93

  
94
	private long counterNewsOIDs = 0;
95
	protected GeometryManager geomManager = GeometryLocator.getGeometryManager();
96

  
97
	public DWGStoreProvider(DWGStoreParameters parameters,
98
			DataStoreProviderServices storeServices) throws InitializeException {
99
		super(parameters, storeServices, FileHelper
100
				.newMetadataContainer(METADATA_DEFINITION_NAME));
101

  
102
		counterNewsOIDs = 0;
103
		//		projection = CRSFactory.getCRS(getParameters().getSRSID());
104

  
105
		File file = getDWGParameters().getFile();
106
		resource = this.createResource(
107
				FileResource.NAME,
108
				new Object[] { file.getAbsolutePath() }
109
			);
110

  
111
		resource.addConsumer(this);
112

  
113
		this.projection = this.getDWGParameters().getCRS();
114

  
115

  
116
		try {
117
			legendBuilder = (LegendBuilder) this.invokeDynMethod(
118
					LegendBuilder.DYNMETHOD_BUILDER_NAME, null);
119
		} catch (DynMethodException e) {
120
			legendBuilder = null;
121
		} catch (Exception e) {
122
			throw new InitializeException(e);
123
		}
124

  
125
		this.initializeFeatureTypes();
126
	}
127

  
128
	private DWGStoreParameters getDWGParameters() {
129
		return (DWGStoreParameters) this.getParameters();
130
	}
131

  
132

  
133
	public String getProviderName() {
134
		return NAME;
135
	}
136

  
137
	public boolean allowWrite() {
138
		return false;
139
	}
140

  
141
	public Object getLegend() throws OpenException {
142
		this.open();
143
		if (legendBuilder == null) {
144
			return null;
145
		}
146
		return legendBuilder.getLegend();
147
	}
148

  
149
	public Object getLabeling() throws OpenException {
150
		this.open();
151
		if (legendBuilder == null) {
152
			return null;
153
		}
154
		return legendBuilder.getLabeling();
155
	}
156

  
157
	private class DWGData {
158
		public ArrayList data = null;
159
		public FeatureType defaultFType = null;
160
		public List fTypes = null;
161
		public Envelope envelope = null;
162
		public IProjection projection;
163
		public LegendBuilder legendBuilder = null;
164
		public Envelope getEnvelopeCopy() throws CreateEnvelopeException {
165
			if (envelope == null) {
166
				return null;
167
			}
168
			Envelope newEnvelope;
169
			if (envelope.getDimension() == 2) {
170
				newEnvelope = geomManager.createEnvelope(SUBTYPES.GEOM2D);
171
			} else {
172
				newEnvelope = geomManager.createEnvelope(SUBTYPES.GEOM3D);
173

  
174
			}
175
			newEnvelope.setLowerCorner(envelope.getLowerCorner());
176
			newEnvelope.setUpperCorner(envelope.getUpperCorner());
177
			return newEnvelope;
178
		}
179
	}
180

  
181
	private AbstractMemoryStoreProvider getStoreProvider() {
182
		return this;
183
	}
184

  
185
	public void open() throws OpenException {
186
		if (this.data != null) {
187
			return;
188
		}
189
		// try {
190
		// this.resource.begin();
191
		// } catch (ResourceExecuteException e2) {
192
		// try {
193
		// throw new OpenException(resource.getName(), e2);
194
		// } catch (AccessResourceException e1) {
195
		// throw new OpenException(this.getName(), e2);
196
		// }
197
		//
198
		// }
199
		try {
200
			getResource().execute(new ResourceAction() {
201
				public Object run() throws Exception {
202
					ResourceProvider resource = getResource();
203
					DWGData dwgData = null;
204
					FeatureStoreProviderServices store = getStoreServices();
205
					if (resource.getData() != null) {
206
						dwgData =
207
								(DWGData) ((Map) resource.getData()).get(projection.getAbrev());
208
						// OJO no es del todo correcto (puede llevar
209
						// reproyeccion)
210
					} else {
211
						resource.setData(new HashMap());
212
					}
213
					if (dwgData == null) {
214
						dwgData = new DWGData();
215
						dwgData.data = new ArrayList();
216
						data = dwgData.data;
217
						counterNewsOIDs = 0;
218
						Reader reader =
219
								new Reader().initialice(getStoreProvider(),
220
										new File((String) resource.get()),
221
										projection, legendBuilder);
222
						reader.begin(store);
223
						dwgData.defaultFType =
224
								reader.getDefaultType().getNotEditableCopy();
225
						ArrayList types = new ArrayList();
226
						Iterator it = reader.getTypes().iterator();
227
						EditableFeatureType fType;
228
						while (it.hasNext()) {
229
							fType = (EditableFeatureType) it.next();
230
							if (fType.getId().equals(
231
									dwgData.defaultFType.getId())) {
232
								types.add(dwgData.defaultFType);
233
							} else {
234
								types.add(fType.getNotEditableCopy());
235
							}
236
						}
237
						dwgData.fTypes = types;
238
						dwgData.legendBuilder = legendBuilder;
239

  
240
						resource.notifyOpen();
241
						store.setFeatureTypes(dwgData.fTypes,
242
								dwgData.defaultFType);
243
						reader.load();
244
						// this.envelope = reader.getEnvelope();
245

  
246
						dwgData.envelope = reader.getEnvelope();
247

  
248

  
249
						dwgData.projection = projection;
250

  
251
						reader.end();
252
						resource.notifyClose();
253
						((Map) resource.getData()).put(projection.getAbrev(),
254
								dwgData); // OJO la reproyeccion
255
					}
256

  
257
					data = dwgData.data;
258
					store.setFeatureTypes(dwgData.fTypes, dwgData.defaultFType);
259
					legendBuilder = dwgData.legendBuilder;
260
					setDynValue("Envelope", dwgData.getEnvelopeCopy());
261
					setDynValue("CRS", projection.getAbrev());
262
					counterNewsOIDs = data.size();
263
					return null;
264
				}
265
			});
266
		} catch (Exception e) {
267
			this.data = null;
268
			try {
269
				throw new OpenException(resource.getName(), e);
270
			} catch (AccessResourceException e1) {
271
				throw new OpenException(this.getProviderName(), e);
272
			}
273
			// } finally {
274
			// this.resource.end();
275
		}
276
	}
277

  
278

  
279
	public DataServerExplorer getExplorer() throws ReadException {
280
		DataManager manager = DALLocator.getDataManager();
281
		FilesystemServerExplorerParameters params;
282
		try {
283
			params = (FilesystemServerExplorerParameters) manager
284
				.createServerExplorerParameters(FilesystemServerExplorer.NAME);
285
			params.setRoot(this.getDWGParameters().getFile().getParent());
286
			return manager.createServerExplorer(params);
287
		} catch (DataException e) {
288
			throw new ReadException(this.getProviderName(), e);
289
		} catch (ValidateDataParametersException e) {
290
			throw new ReadException(this.getProviderName(), e);
291
		}
292

  
293
	}
294

  
295

  
296

  
297
	public void performChanges(Iterator deleteds, Iterator inserteds, Iterator updateds, Iterator originalFeatureTypesUpdated) throws PerformEditingException {
298
		// FIXME Exception
299
		throw new UnsupportedOperationException();
300
	}
301

  
302
	public class Reader {
303
		private File file;
304
		private String fileName;
305
		private IProjection projection;
306
		private List types;
307
		private LegendBuilder leyendBuilder;
308
		private AbstractMemoryStoreProvider store;
309
		private Envelope envelope;
310

  
311
		public Reader initialice(AbstractMemoryStoreProvider store, File file,
312
				IProjection projection,
313
				LegendBuilder leyendBuilder) {
314
			this.store = store;
315
			this.file = file;
316
			this.fileName = file.getAbsolutePath();
317
			this.projection = projection;
318
			this.leyendBuilder = leyendBuilder;
319
			if (leyendBuilder != null) {
320
				leyendBuilder.initialize(store);
321
			}
322
			return this;
323
		}
324

  
325
		public Envelope getEnvelope() {
326
			return this.envelope;
327
		}
328

  
329
		public void begin(FeatureStoreProviderServices store) {
330

  
331
			EditableFeatureType featureType = store.createFeatureType();
332

  
333
			featureType.setHasOID(true);
334

  
335
			ID_FIELD_ID = featureType.add(NAME_FIELD_ID, DataTypes.INT)
336
					.setDefaultValue(Integer.valueOf(0))
337
				.getIndex();
338

  
339
			EditableFeatureAttributeDescriptor attr = featureType.add(
340
					NAME_FIELD_GEOMETRY, DataTypes.GEOMETRY);
341
			attr.setSRS(this.projection);
342
			attr.setGeometryType(Geometry.TYPES.GEOMETRY);
343
			ID_FIELD_GEOMETRY = attr.getIndex();
344

  
345
			featureType.setDefaultGeometryAttributeName(NAME_FIELD_GEOMETRY);
346

  
347
			// FIXME: Cual es el size y el valor por defecto para Entity ?
348
			ID_FIELD_ENTITY = featureType.add(NAME_FIELD_ENTITY,
349
					DataTypes.STRING, 100)
350
					.setDefaultValue("")
351
					.getIndex();
352

  
353
			// FIXME: Cual es el size de Layer ?
354
			ID_FIELD_LAYER = featureType.add(NAME_FIELD_LAYER,
355
					DataTypes.STRING, 100)
356
					.setDefaultValue(
357
					"default").getIndex();
358

  
359
			ID_FIELD_COLOR = featureType.add(NAME_FIELD_COLOR,
360
					DataTypes.INT)
361
					.setDefaultValue(
362
					Integer.valueOf(0)).getIndex();
363

  
364
			ID_FIELD_ELEVATION = featureType.add(NAME_FIELD_ELEVATION,
365
					DataTypes.DOUBLE)
366
					.setDefaultValue(
367
					Double.valueOf(0)).getIndex();
368

  
369
			ID_FIELD_THICKNESS = featureType.add(NAME_FIELD_THICKNESS,
370
					DataTypes.DOUBLE)
371
					.setDefaultValue(
372
					Double.valueOf(0)).getIndex();
373

  
374
			// FIXME: Cual es el size de Text ?
375
			ID_FIELD_TEXT = featureType.add(NAME_FIELD_TEXT,
376
					DataTypes.STRING, 100)
377
					.setDefaultValue("")
378
					.getIndex();
379

  
380
			ID_FIELD_HEIGHTTEXT = featureType.add(NAME_FIELD_HEIGHTTEXT,
381
					DataTypes.DOUBLE).setDefaultValue(
382
					Double.valueOf(10)).getIndex();
383

  
384
			ID_FIELD_ROTATIONTEXT = featureType.add(NAME_FIELD_ROTATIONTEXT,
385
					DataTypes.DOUBLE).setDefaultValue(
386
					Double.valueOf(0)).getIndex();
387

  
388

  
389

  
390
			// FIXME: Parece que el DXF puede tener mas atributos opcionales.
391
			// Habria que ver de pillarlos ?
392

  
393
			types = new ArrayList();
394
			types.add(featureType);
395

  
396
			if (leyendBuilder != null) {
397
				leyendBuilder.begin();
398
			}
399

  
400
		}
401

  
402
		public void end() {
403
			if (leyendBuilder != null) {
404
				leyendBuilder.end();
405
			}
406
		}
407

  
408
		public List getTypes() {
409
			return types;
410
		}
411

  
412
		public EditableFeatureType getDefaultType() {
413
			return (EditableFeatureType) types.get(0);
414
		}
415

  
416
		private Double toDouble(String value) {
417
			if (value == null) {
418
				return Double.valueOf(0);
419
			}
420
			return Double.valueOf(value);
421
		}
422

  
423
		public void load() throws DataException {
424

  
425
			this.envelope = null;
426

  
427
			DwgFile dwgFeatureFile = new DwgFile(file.getAbsolutePath());
428

  
429
			try {
430
				dwgFeatureFile.read();
431
			} catch (DwgVersionNotSupportedException e1) {
432
				throw new UnsupportedDWGVersionException(file.getName(), e1);
433
			} catch (IOException e) {
434
				throw new ReadException(NAME, e);
435
			}
436

  
437

  
438
			dwgFeatureFile.calculateGisModelDwgPolylines();
439
			dwgFeatureFile.blockManagement2();
440
			List entities = dwgFeatureFile.getDwgObjects();
441

  
442
			int id = -1;
443
			try{
444
				int envelopeSubType = Geometry.SUBTYPES.GEOM2D;
445
				boolean is3dFile = dwgFeatureFile.isDwg3DFile();
446
//				if (is3dFile) {
447
//					envelopeSubType = Geometry.SUBTYPES.GEOM3D;
448
//				}
449

  
450
				this.envelope = geomManager.createEnvelope(envelopeSubType);
451

  
452
				boolean updateEnvelope = true;
453

  
454
				double[] extMin = (double[]) dwgFeatureFile
455
						.getHeader("MSPACE_EXTMIN");
456
				double[] extMax = (double[]) dwgFeatureFile
457
						.getHeader("MSPACE_EXTMAX");
458
				if (extMin != null && extMax != null) {
459
					updateEnvelope = false;
460
					Point point = (Point) geomManager.create(
461
							Geometry.TYPES.POINT, envelopeSubType);
462
					point.setCoordinates(extMin);
463
					this.envelope.setLowerCorner(point);
464
					point = (Point) geomManager.create(Geometry.TYPES.POINT,
465
							envelopeSubType);
466
					point.setCoordinates(extMax);
467
					this.envelope.setUpperCorner(point);
468
				}
469

  
470

  
471
				Iterator iter = entities.iterator();
472

  
473
				FeatureProvider featureProvider;
474
				Envelope gEnvelope;
475

  
476
				while (iter.hasNext()) {
477
					id++;
478
					DwgObject entity = (DwgObject) iter.next();
479

  
480
					if (!(entity instanceof IDwg2FMap)) {
481
						logger
482
								.warn(
483
								"load: entity type {}(id:{}) not loadded",
484
														new Object[] { entity
485
																.getType() },
486
														id);
487

  
488
						continue;
489
					}
490

  
491
					IDwg2FMap dwgEnt = (IDwg2FMap) entity;
492
					Geometry geometry = dwgEnt.toFMapGeometry(is3dFile);
493
					if (geometry == null) { // || geometry.getGeneralPath() ==
494
						// null) {
495
						logger
496
								.warn(
497
								"load: entity {}(id:{}) with null geometry",
498
														new Object[] {
499
																entity
500
																		.getType(),
501
																id });
502

  
503
						continue;
504
					}
505
					// FIXME: Estas 6 lineas es por si la geometr??a no se ha
506
					// creado correctamente
507
					gEnvelope = null;
508
					try {
509
						gEnvelope = geometry.getEnvelope();
510
					} catch (Exception e) {
511
						gEnvelope = null;
512
					}
513
					if (gEnvelope == null) {
514
						logger
515
								.warn(
516
								"load: entity {}(id:{}) with null envelope",
517
								new Object[] { entity.getType(), id });
518

  
519
						continue;
520
					}
521
					// we check for Region of Interest of the CAD file
522
					if (!this.envelope.intersects(geometry.getEnvelope())) {
523
						logger
524
								.warn(
525
								"load: entity {}(id:{}) out of envelope",
526
								new Object[] { entity.getType(), id });
527
						continue;
528
					}
529
					featureProvider = store.createFeatureProvider(store
530
							.getStoreServices().getDefaultFeatureType());
531

  
532
					featureProvider.set(ID_FIELD_ID, id);
533

  
534
					featureProvider.set(ID_FIELD_ENTITY, dwgEnt.toString());
535

  
536
					featureProvider.set(ID_FIELD_LAYER, dwgFeatureFile
537
							.getLayerName(entity));
538

  
539
					int colorByLayer = dwgFeatureFile.getColorByLayer(entity);
540
					int color = entity.getColor();
541
					if (color < 0) {
542
						color = Math.abs(color);
543
					}
544
					if (color > 255) {
545
						color = colorByLayer;
546
					}
547

  
548
					featureProvider.set(ID_FIELD_COLOR, color);
549

  
550
					if (entity instanceof IDwg3DTestable) {
551
						featureProvider.set(ID_FIELD_ELEVATION,
552
								((IDwg3DTestable) entity).getZ());
553
					}
554

  
555
					featureProvider.set(ID_FIELD_THICKNESS, 0.0);
556
					featureProvider.set(ID_FIELD_HEIGHTTEXT, 0.0);
557
					featureProvider.set(ID_FIELD_ROTATIONTEXT, 0.0);
558
					featureProvider.set(ID_FIELD_TEXT, "");
559

  
560
					if (entity instanceof DwgMText) {
561
						DwgMText mtext = (DwgMText) entity;
562
						featureProvider.set(ID_FIELD_HEIGHTTEXT, mtext.getHeight());
563
						featureProvider.set(ID_FIELD_TEXT, mtext.getText());
564
					} else if (entity instanceof DwgText) {
565
						DwgText text = (DwgText) entity;
566
						featureProvider
567
								.set(ID_FIELD_THICKNESS, text.getThickness());
568
						featureProvider.set(ID_FIELD_HEIGHTTEXT, text.getHeight());
569
						featureProvider.set(ID_FIELD_ROTATIONTEXT, text
570
								.getRotationAngle());
571
						featureProvider.set(ID_FIELD_TEXT, text.getText());
572
					}// if-else
573

  
574
					featureProvider.setDefaultGeometry(geometry);
575

  
576
					store.addFeatureProvider(featureProvider);
577
					if (this.leyendBuilder != null) {
578
						this.leyendBuilder.process(featureProvider);
579
					}
580

  
581
				}
582

  
583
			} catch (org.gvsig.fmap.geom.exception.CreateGeometryException e) {
584
				throw new CreateGeometryException(e);
585
			} catch (org.gvsig.fmap.geom.exception.CreateEnvelopeException e) {
586
				throw new CreateGeometryException(e);
587
			}
588

  
589
		}
590

  
591
	}
592

  
593

  
594
	public boolean closeResourceRequested(ResourceProvider resource) {
595
		return true;
596
	}
597

  
598
	public int getOIDType() {
599
		return DataTypes.LONG;
600
	}
601

  
602
	public boolean supportsAppendMode() {
603
		return false;
604
	}
605

  
606
	public void append(FeatureProvider featureProvider) {
607
		// FIXME Exception
608
		throw new UnsupportedOperationException();
609
	}
610

  
611
	public void beginAppend() {
612
		// FIXME Exception
613
		throw new UnsupportedOperationException();
614

  
615
	}
616

  
617
	public void endAppend() {
618
		// FIXME Exception
619
		throw new UnsupportedOperationException();
620
	}
621

  
622
	public void saveToState(PersistentState state) throws PersistenceException {
623
		// TODO Auto-generated method stub
624
		throw new NotYetImplemented();
625
	}
626

  
627
	public void loadFromState(PersistentState state) throws PersistenceException {
628
		// TODO Auto-generated method stub
629
		throw new NotYetImplemented();
630
	}
631

  
632
	public Object createNewOID() {
633
		return new Long(counterNewsOIDs++);
634
	}
635

  
636
	protected void initializeFeatureTypes() throws InitializeException {
637
		try {
638
			this.open();
639
		} catch (OpenException e) {
640
			throw new InitializeException(this.getProviderName(), e);
641
		}
642
	}
643

  
644
	public Envelope getEnvelope() throws DataException {
645
		this.open();
646
		return (Envelope) this.getDynValue("Envelope");
647
	}
648

  
649

  
650
	/*
651
	 * (non-Javadoc)
652
	 *
653
	 * @see
654
	 * org.gvsig.fmap.dal.resource.spi.ResourceConsumer#resourceChanged(org.
655
	 * gvsig.fmap.dal.resource.spi.ResourceProvider)
656
	 */
657
	public void resourceChanged(ResourceProvider resource) {
658
		this.getStoreServices().notifyChange(
659
				DataStoreNotification.RESOURCE_CHANGED,
660
				resource);
661
	}
662

  
663
	public Object getSourceId() {
664
		return this.getDWGParameters().getFile();
665
	}
666

  
667

  
668
	public String getName() {
669
		String name = this.getDWGParameters().getFile().getName();
670
		int n = name.lastIndexOf(".");
671
		if( n<1 ) {
672
			return name;
673
		}
674
		return name.substring(0, n);
675
	}
676
	
677
	public String getFullName() {
678
		return this.getDWGParameters().getFile().getAbsolutePath();
679
	}
680
	
681

  
682
	
683
	public ResourceProvider getResource() {
684
		return resource;
685
	}
686

  
687
}
0 688

  
tags/v2_0_0_Build_2020/extensions/extDwg/src/org/gvsig/dwg/fmap/dal/store/dwg/legend/DWGLegendLibrary.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. S.A.   {{Task}}
26
*/
27

  
28
/**
29
 *
30
 */
31
package org.gvsig.dwg.fmap.dal.store.dwg.legend;
32

  
33
import org.gvsig.dwg.fmap.dal.store.dwg.DWGLibrary;
34
import org.gvsig.dwg.fmap.dal.store.dwg.DWGStoreProvider;
35
import org.gvsig.metadata.MetadataLibrary;
36
import org.gvsig.metadata.MetadataLocator;
37
import org.gvsig.tools.dynobject.DynClass;
38
import org.gvsig.tools.library.AbstractLibrary;
39
import org.gvsig.tools.library.Library;
40
import org.gvsig.tools.library.LibraryException;
41

  
42
/**
43
 * @author jmvivo
44
 *
45
 */
46
public class DWGLegendLibrary extends AbstractLibrary {
47

  
48
	public DWGLegendLibrary() {
49
		super(DWGLegendLibrary.class, Library.TYPE.IMPL);
50
		require(MetadataLibrary.class);
51
		require(DWGLibrary.class);
52
	}
53
	
54
	@Override
55
	protected void doInitialize() throws LibraryException {
56
	}
57

  
58
	@Override
59
	protected void doPostInitialize() throws LibraryException {
60
		DynClass dynClass = (DynClass) MetadataLocator.getMetadataManager()
61
				.getDefinition(DWGStoreProvider.METADATA_DEFINITION_NAME);
62

  
63
		DWGGetLegendBuilder.register(dynClass);
64
		DWGGetLegend.register(dynClass);
65
		DWGGetLabeling.register(dynClass);
66
	}
67
}
0 68

  
tags/v2_0_0_Build_2020/extensions/extDwg/src/org/gvsig/dwg/fmap/dal/store/dwg/legend/DWGGetLegendBuilder.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. S.A.   {{Task}}
26
*/
27

  
28
package org.gvsig.dwg.fmap.dal.store.dwg.legend;
29

  
30
import org.gvsig.dwg.fmap.dal.store.dwg.LegendBuilder;
31
import org.gvsig.tools.ToolsLocator;
32
import org.gvsig.tools.dynobject.DynClass;
33
import org.gvsig.tools.dynobject.DynMethod;
34
import org.gvsig.tools.dynobject.DynObject;
35
import org.gvsig.tools.dynobject.exception.DynMethodException;
36
import org.gvsig.tools.dynobject.exception.DynMethodNotSupportedException;
37

  
38
public class DWGGetLegendBuilder implements DynMethod {
39
	private static Integer code = null;
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff