Revision 407
org.gvsig.dxf/tags/org.gvsig.dxf-2.0.91/org.gvsig.dxf.exportto/src/main/java/org/gvsig/export/dxf/ExportDXFLibrary.java | ||
---|---|---|
1 |
package org.gvsig.export.dxf; |
|
2 |
|
|
3 |
|
|
4 |
import org.gvsig.export.ExportLibrary; |
|
5 |
import org.gvsig.export.ExportLocator; |
|
6 |
import org.gvsig.export.dxf.service.ExportDXFServiceFactory; |
|
7 |
import org.gvsig.export.dxf.swing.ExportDXFPanelsFactory; |
|
8 |
import org.gvsig.export.spi.ExportServiceManager; |
|
9 |
import org.gvsig.export.swing.ExportSwingLibrary; |
|
10 |
import org.gvsig.export.swing.ExportSwingLocator; |
|
11 |
import org.gvsig.export.swing.spi.ExportPanelsManager; |
|
12 |
import org.gvsig.tools.library.AbstractLibrary; |
|
13 |
import org.gvsig.tools.library.LibraryException; |
|
14 |
|
|
15 |
|
|
16 |
/** |
|
17 |
* |
|
18 |
* @author jjdelcerro |
|
19 |
*/ |
|
20 |
public class ExportDXFLibrary extends AbstractLibrary { |
|
21 |
|
|
22 |
@Override |
|
23 |
public void doRegistration() { |
|
24 |
registerAsServiceOf(ExportSwingLibrary.class); |
|
25 |
registerAsServiceOf(ExportLibrary.class); |
|
26 |
} |
|
27 |
|
|
28 |
@Override |
|
29 |
protected void doInitialize() throws LibraryException { |
|
30 |
// Nothing to do |
|
31 |
} |
|
32 |
|
|
33 |
@Override |
|
34 |
protected void doPostInitialize() throws LibraryException { |
|
35 |
ExportServiceManager manager = ExportLocator.getServiceManager(); |
|
36 |
ExportPanelsManager swingManager = ExportSwingLocator.getExportPanelsManager(); |
|
37 |
|
|
38 |
manager.register(new ExportDXFServiceFactory()); |
|
39 |
swingManager.register(new ExportDXFPanelsFactory()); |
|
40 |
} |
|
41 |
|
|
42 |
} |
org.gvsig.dxf/tags/org.gvsig.dxf-2.0.91/org.gvsig.dxf.exportto/src/main/java/org/gvsig/export/dxf/service/ExportDXFServiceFactory.java | ||
---|---|---|
1 |
package org.gvsig.export.dxf.service; |
|
2 |
|
|
3 |
import org.gvsig.export.ExportParameters; |
|
4 |
import org.gvsig.export.spi.AbstractExportServiceFactory; |
|
5 |
|
|
6 |
/** |
|
7 |
* |
|
8 |
* @author jjdelcerro |
|
9 |
*/ |
|
10 |
public class ExportDXFServiceFactory |
|
11 |
extends AbstractExportServiceFactory |
|
12 |
{ |
|
13 |
|
|
14 |
public static final String SERVICE_NAME = "DXF"; |
|
15 |
|
|
16 |
public ExportDXFServiceFactory() { |
|
17 |
super( |
|
18 |
SERVICE_NAME, |
|
19 |
"DXF file", |
|
20 |
"DXF file" |
|
21 |
); |
|
22 |
} |
|
23 |
|
|
24 |
@Override |
|
25 |
public ExportDXFService createService(ExportParameters parameters) { |
|
26 |
ExportDXFService service = new ExportDXFService(this, (ExportDXFParameters) parameters); |
|
27 |
return service; |
|
28 |
} |
|
29 |
|
|
30 |
@Override |
|
31 |
public ExportDXFParameters createParameters() { |
|
32 |
ExportDXFParameters parameters = new ExportDXFParametersImpl(); |
|
33 |
return parameters; |
|
34 |
} |
|
35 |
|
|
36 |
@Override |
|
37 |
public boolean hasTabularSupport() { |
|
38 |
return true; |
|
39 |
} |
|
40 |
|
|
41 |
@Override |
|
42 |
public boolean hasVectorialSupport() { |
|
43 |
return true; |
|
44 |
} |
|
45 |
|
|
46 |
} |
org.gvsig.dxf/tags/org.gvsig.dxf-2.0.91/org.gvsig.dxf.exportto/src/main/java/org/gvsig/export/dxf/service/ExportDXFService.java | ||
---|---|---|
1 |
package org.gvsig.export.dxf.service; |
|
2 |
|
|
3 |
import org.gvsig.export.ExportException; |
|
4 |
import org.gvsig.export.ExportLocator; |
|
5 |
import org.gvsig.export.spi.AbstractExportService; |
|
6 |
import org.gvsig.export.spi.AttributeNamesTranslator; |
|
7 |
import org.gvsig.export.spi.ExportService; |
|
8 |
import org.gvsig.export.spi.ExportServiceFactory; |
|
9 |
import org.gvsig.fmap.dal.DALLocator; |
|
10 |
import org.gvsig.fmap.dal.DataManager; |
|
11 |
import org.gvsig.fmap.dal.DataServerExplorer; |
|
12 |
import org.gvsig.fmap.dal.NewDataStoreParameters; |
|
13 |
import org.gvsig.fmap.dal.OpenDataStoreParameters; |
|
14 |
import org.gvsig.fmap.dal.exception.DataException; |
|
15 |
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor; |
|
16 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
|
17 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
18 |
import org.gvsig.fmap.dal.feature.NewFeatureStoreParameters; |
|
19 |
import org.gvsig.fmap.dal.feature.OpenFeatureStoreParameters; |
|
20 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorer; |
|
21 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorerParameters; |
|
22 |
import org.gvsig.tools.util.HasAFile; |
|
23 |
|
|
24 |
/** |
|
25 |
* |
|
26 |
* @author jjdelcerro |
|
27 |
*/ |
|
28 |
public class ExportDXFService |
|
29 |
extends AbstractExportService |
|
30 |
implements ExportService |
|
31 |
{ |
|
32 |
|
|
33 |
public static final int MAX_FIELD_NAME_LENGTH = 10; |
|
34 |
|
|
35 |
protected ExportDXFService(ExportServiceFactory factory, ExportDXFParameters parameters) { |
|
36 |
super(factory, parameters); |
|
37 |
} |
|
38 |
|
|
39 |
@Override |
|
40 |
public ExportDXFParameters getParameters() { |
|
41 |
return (ExportDXFParameters) super.getParameters(); |
|
42 |
} |
|
43 |
|
|
44 |
@Override |
|
45 |
protected DataServerExplorer createServerExplorer() throws ExportException{ |
|
46 |
|
|
47 |
DataManager dataManager = DALLocator.getDataManager(); |
|
48 |
|
|
49 |
FilesystemServerExplorerParameters explorerParams; |
|
50 |
try { |
|
51 |
explorerParams = |
|
52 |
(FilesystemServerExplorerParameters) dataManager |
|
53 |
.createServerExplorerParameters(FilesystemServerExplorer.NAME); |
|
54 |
} catch (Exception e) { |
|
55 |
throw new ExportException(e); |
|
56 |
} |
|
57 |
explorerParams.setRoot(this.getParameters().getFile().getParent()); |
|
58 |
|
|
59 |
FilesystemServerExplorer explorer; |
|
60 |
try { |
|
61 |
explorer = (FilesystemServerExplorer) dataManager.openServerExplorer( |
|
62 |
"FilesystemExplorer", explorerParams |
|
63 |
); |
|
64 |
return explorer; |
|
65 |
} catch (Exception e) { |
|
66 |
throw new ExportException(e); |
|
67 |
} |
|
68 |
} |
|
69 |
|
|
70 |
@Override |
|
71 |
protected NewDataStoreParameters createTargetNewStoreParameters() throws ExportException { |
|
72 |
try { |
|
73 |
FilesystemServerExplorer explorer = (FilesystemServerExplorer) this.createServerExplorer(); |
|
74 |
NewFeatureStoreParameters newStoreParameters = (NewFeatureStoreParameters) explorer.getAddParameters( |
|
75 |
this.getParameters().getFile() |
|
76 |
); |
|
77 |
newStoreParameters.setDynValue("CRS", this.getParameters().getTargetProjection()); |
|
78 |
// Usamos el featureType por defecto del DXF. |
|
79 |
return newStoreParameters; |
|
80 |
} catch (DataException ex) { |
|
81 |
throw new ExportException(ex); |
|
82 |
} |
|
83 |
} |
|
84 |
|
|
85 |
@Override |
|
86 |
public OpenDataStoreParameters createTargetOpenStoreParameters() throws ExportException { |
|
87 |
try { |
|
88 |
DataManager dataManager = DALLocator.getDataManager(); |
|
89 |
OpenFeatureStoreParameters openStoreParameters = (OpenFeatureStoreParameters) dataManager.createStoreParameters("DXF"); |
|
90 |
((HasAFile)openStoreParameters).setFile(getParameters().getFile()); |
|
91 |
openStoreParameters.setDynValue("CRS", this.getParameters().getTargetProjection()); |
|
92 |
return openStoreParameters; |
|
93 |
} catch (DataException ex) { |
|
94 |
throw new ExportException(ex); |
|
95 |
} |
|
96 |
} |
|
97 |
|
|
98 |
|
|
99 |
|
|
100 |
|
|
101 |
} |
org.gvsig.dxf/tags/org.gvsig.dxf-2.0.91/org.gvsig.dxf.exportto/src/main/java/org/gvsig/export/dxf/service/ExportDXFParameters.java | ||
---|---|---|
1 |
package org.gvsig.export.dxf.service; |
|
2 |
|
|
3 |
import org.gvsig.export.ExportParametersGeometry; |
|
4 |
import org.gvsig.tools.util.HasAFile; |
|
5 |
|
|
6 |
/** |
|
7 |
* |
|
8 |
* @author jjdelcerro |
|
9 |
*/ |
|
10 |
public interface ExportDXFParameters extends ExportParametersGeometry, HasAFile { |
|
11 |
|
|
12 |
} |
org.gvsig.dxf/tags/org.gvsig.dxf-2.0.91/org.gvsig.dxf.exportto/src/main/java/org/gvsig/export/dxf/service/ExportDXFParametersImpl.java | ||
---|---|---|
1 |
package org.gvsig.export.dxf.service; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
import org.apache.commons.io.FilenameUtils; |
|
5 |
import org.gvsig.export.spi.AbstractExportParametersGeometry; |
|
6 |
|
|
7 |
/** |
|
8 |
* |
|
9 |
* @author jjdelcerro |
|
10 |
*/ |
|
11 |
public class ExportDXFParametersImpl |
|
12 |
extends AbstractExportParametersGeometry |
|
13 |
implements ExportDXFParameters |
|
14 |
{ |
|
15 |
private File file; |
|
16 |
|
|
17 |
@Override |
|
18 |
public String getServiceName() { |
|
19 |
return ExportDXFServiceFactory.SERVICE_NAME; |
|
20 |
} |
|
21 |
|
|
22 |
@Override |
|
23 |
public File getFile() { |
|
24 |
return this.file; |
|
25 |
} |
|
26 |
|
|
27 |
@Override |
|
28 |
public void setFile(File file) { |
|
29 |
this.file = new File(FilenameUtils.removeExtension(file.getAbsolutePath()) + ".dxf"); |
|
30 |
} |
|
31 |
|
|
32 |
} |
org.gvsig.dxf/tags/org.gvsig.dxf-2.0.91/org.gvsig.dxf.exportto/src/main/java/org/gvsig/export/dxf/swing/ExportDXFPanels.java | ||
---|---|---|
1 |
/* |
|
2 |
* To change this license header, choose License Headers in Project Properties. |
|
3 |
* To change this template file, choose Tools | Templates |
|
4 |
* and open the template in the editor. |
|
5 |
*/ |
|
6 |
package org.gvsig.export.dxf.swing; |
|
7 |
|
|
8 |
import org.gvsig.export.ExportParameters; |
|
9 |
import org.gvsig.export.swing.ExportSwingLocator; |
|
10 |
import org.gvsig.export.swing.JExportProcessPanel; |
|
11 |
import org.gvsig.export.swing.spi.AbstractExportPanels; |
|
12 |
import org.gvsig.export.swing.spi.ExportPanels; |
|
13 |
import org.gvsig.export.swing.spi.ExportPanelsFactory; |
|
14 |
import org.gvsig.export.swing.spi.ExportPanelsManager; |
|
15 |
import org.gvsig.fmap.geom.Geometry; |
|
16 |
|
|
17 |
/** |
|
18 |
* |
|
19 |
* @author jjdelcerro |
|
20 |
*/ |
|
21 |
public class ExportDXFPanels |
|
22 |
extends AbstractExportPanels |
|
23 |
implements ExportPanels |
|
24 |
{ |
|
25 |
|
|
26 |
ExportDXFPanels( |
|
27 |
ExportPanelsFactory factory, |
|
28 |
JExportProcessPanel processPanel, |
|
29 |
ExportParameters parameters |
|
30 |
) { |
|
31 |
super(factory, processPanel, parameters); |
|
32 |
this.initPanels(); |
|
33 |
} |
|
34 |
|
|
35 |
private void initPanels() { |
|
36 |
ExportPanelsManager manager = ExportSwingLocator.getExportPanelsManager(); |
|
37 |
|
|
38 |
this.add( manager.createStandardPanel( |
|
39 |
ExportPanelsManager.PANEL_SELECT_GEOMETRY_FIELD, |
|
40 |
this.getProcessPanel(), |
|
41 |
this.getParameters() |
|
42 |
) |
|
43 |
); |
|
44 |
// this.add( manager.createStandardPanel( |
|
45 |
// ExportPanelsManager.PANEL_SELECT_GEOMETRY_TYPE, |
|
46 |
// this.getProcessPanel(), |
|
47 |
// this.getParameters(), |
|
48 |
// new int[] { |
|
49 |
// Geometry.TYPES.GEOMETRY, |
|
50 |
// Geometry.TYPES.POINT, |
|
51 |
// Geometry.TYPES.LINE, |
|
52 |
// Geometry.TYPES.POLYGON, |
|
53 |
// Geometry.TYPES.MULTIPOINT, |
|
54 |
// Geometry.TYPES.MULTILINE, |
|
55 |
// Geometry.TYPES.MULTIPOLYGON |
|
56 |
// }, |
|
57 |
// new int[] { |
|
58 |
// Geometry.SUBTYPES.GEOM2D, |
|
59 |
// Geometry.SUBTYPES.GEOM3D, |
|
60 |
// Geometry.SUBTYPES.GEOM3DM |
|
61 |
// } |
|
62 |
// ) |
|
63 |
// ); |
|
64 |
this.add( manager.createStandardPanel( |
|
65 |
ExportPanelsManager.PANEL_CHECK_GEOMETRIES, |
|
66 |
this.getProcessPanel(), |
|
67 |
this.getParameters() |
|
68 |
) |
|
69 |
); |
|
70 |
this.add( manager.createStandardPanel( |
|
71 |
ExportPanelsManager.PANEL_SELECT_OUTPUT_FILE, |
|
72 |
this.getProcessPanel(), |
|
73 |
this.getParameters() |
|
74 |
) |
|
75 |
); |
|
76 |
} |
|
77 |
} |
org.gvsig.dxf/tags/org.gvsig.dxf-2.0.91/org.gvsig.dxf.exportto/src/main/java/org/gvsig/export/dxf/swing/ExportDXFPanelsFactory.java | ||
---|---|---|
1 |
package org.gvsig.export.dxf.swing; |
|
2 |
|
|
3 |
import org.gvsig.export.ExportParameters; |
|
4 |
import org.gvsig.export.dxf.service.ExportDXFServiceFactory; |
|
5 |
import org.gvsig.export.swing.JExportProcessPanel; |
|
6 |
import org.gvsig.export.swing.spi.AbstractExportPanelsFactory; |
|
7 |
import org.gvsig.export.swing.spi.ExportPanels; |
|
8 |
import org.gvsig.export.swing.spi.ExportPanelsFactory; |
|
9 |
|
|
10 |
/** |
|
11 |
* |
|
12 |
* @author jjdelcerro |
|
13 |
*/ |
|
14 |
public class ExportDXFPanelsFactory |
|
15 |
extends AbstractExportPanelsFactory |
|
16 |
implements ExportPanelsFactory { |
|
17 |
|
|
18 |
public ExportDXFPanelsFactory() { |
|
19 |
super(ExportDXFServiceFactory.SERVICE_NAME); |
|
20 |
} |
|
21 |
|
|
22 |
@Override |
|
23 |
public ExportPanels createPanels(JExportProcessPanel processPanel, ExportParameters parameters) { |
|
24 |
return new ExportDXFPanels(this, processPanel, parameters); |
|
25 |
} |
|
26 |
|
|
27 |
} |
org.gvsig.dxf/tags/org.gvsig.dxf-2.0.91/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.91/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.91</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.tools.swing.api</artifactId> |
|
21 |
<scope>compile</scope> |
|
22 |
</dependency> |
|
23 |
<dependency> |
|
24 |
<groupId>org.gvsig</groupId> |
|
25 |
<artifactId>org.gvsig.tools.lib</artifactId> |
|
26 |
<scope>compile</scope> |
|
27 |
</dependency> |
|
28 |
<dependency> |
|
29 |
<groupId>org.gvsig</groupId> |
|
30 |
<artifactId>org.gvsig.fmap.dal.api</artifactId> |
|
31 |
<scope>compile</scope> |
|
32 |
</dependency> |
|
33 |
<dependency> |
|
34 |
<groupId>org.gvsig</groupId> |
|
35 |
<artifactId>org.gvsig.fmap.geometry.api</artifactId> |
|
36 |
<scope>compile</scope> |
|
37 |
</dependency> |
|
38 |
<dependency> |
|
39 |
<groupId>org.gvsig</groupId> |
|
40 |
<artifactId>org.gvsig.projection.api</artifactId> |
|
41 |
<scope>compile</scope> |
|
42 |
</dependency> |
|
43 |
<dependency> |
|
44 |
<groupId>org.gvsig</groupId> |
|
45 |
<artifactId>org.gvsig.metadata.lib.basic.api</artifactId> |
|
46 |
<scope>compile</scope> |
|
47 |
</dependency> |
|
48 |
</dependencies> |
|
49 |
</project> |
|
50 |
|
|
51 |
|
|
0 | 52 |
org.gvsig.dxf/tags/org.gvsig.dxf-2.0.91/org.gvsig.dxf.lib/src/main/java/org/gvsig/dxf/geo/.cvsignore | ||
---|---|---|
1 |
*.dfPackage |
|
2 |
*.wmf |
org.gvsig.dxf/tags/org.gvsig.dxf-2.0.91/org.gvsig.dxf.lib/src/main/java/org/gvsig/dxf/geo/Polygon2D.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.geo; |
|
25 |
|
|
26 |
import java.awt.Graphics2D; |
|
27 |
import java.awt.geom.GeneralPath; |
|
28 |
import java.awt.geom.Point2D; |
|
29 |
|
|
30 |
import java.util.Iterator; |
|
31 |
import java.util.Vector; |
|
32 |
|
|
33 |
import org.cresques.geo.ViewPortData; |
|
34 |
|
|
35 |
|
|
36 |
/** |
|
37 |
* Clase que representa un pol?gono 2D |
|
38 |
* @author "Luis W. Sevilla" <sevilla_lui@gva.es> |
|
39 |
*/ |
|
40 |
public class Polygon2D extends Vector { |
|
41 |
GeneralPath gp = null; |
|
42 |
|
|
43 |
public Polygon2D() { |
|
44 |
super(); |
|
45 |
gp = null; |
|
46 |
} |
|
47 |
|
|
48 |
/** |
|
49 |
* A?ade un vertice al po??gono |
|
50 |
* @param pt punto 2D que representa el vertice a?adido |
|
51 |
*/ |
|
52 |
public void addPoint(Point2D pt) { |
|
53 |
super.add(pt); |
|
54 |
} |
|
55 |
|
|
56 |
/** |
|
57 |
* Dibuja el pol?gono |
|
58 |
* @param g Graphics sobre el que dibuja |
|
59 |
* @param vp ViewPort con la vista |
|
60 |
*/ |
|
61 |
public void draw(Graphics2D g, ViewPortData vp) { |
|
62 |
newGP(vp); |
|
63 |
g.draw(gp); |
|
64 |
|
|
65 |
//g.draw(new Line2D.Double(pt,pt0)); |
|
66 |
} |
|
67 |
|
|
68 |
/** |
|
69 |
* |
|
70 |
* @param g |
|
71 |
* @param vp |
|
72 |
*/ |
|
73 |
public void fill(Graphics2D g, ViewPortData vp) { |
|
74 |
newGP(vp); |
|
75 |
g.fill(gp); |
|
76 |
} |
|
77 |
|
|
78 |
/** |
|
79 |
* |
|
80 |
* @param vp |
|
81 |
*/ |
|
82 |
private void newGP(ViewPortData vp) { |
|
83 |
//if (gp != null) return; |
|
84 |
gp = new GeneralPath(); |
|
85 |
|
|
86 |
Point2D pt0 = null; |
|
87 |
Point2D pt = null; |
|
88 |
Point2D pt1 = null; |
|
89 |
Point2D.Double ptTmp = new Point2D.Double(0.0, 0.0); |
|
90 |
Iterator iter = iterator(); |
|
91 |
|
|
92 |
while (iter.hasNext()) { |
|
93 |
pt1 = (Point2D) iter.next(); |
|
94 |
vp.mat.transform(pt1, ptTmp); |
|
95 |
|
|
96 |
if (pt0 == null) { |
|
97 |
pt0 = ptTmp; |
|
98 |
gp.moveTo((float) ptTmp.getX(), (float) ptTmp.getY()); |
|
99 |
} else { |
|
100 |
gp.lineTo((float) ptTmp.getX(), (float) ptTmp.getY()); |
|
101 |
} |
|
102 |
} |
|
103 |
|
|
104 |
gp.closePath(); |
|
105 |
} |
|
106 |
} |
org.gvsig.dxf/tags/org.gvsig.dxf-2.0.91/org.gvsig.dxf.lib/src/main/java/org/gvsig/dxf/geo/cover/Hoja.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.geo.cover; |
|
25 |
|
|
26 |
import org.cresques.cts.ICoordTrans; |
|
27 |
import org.cresques.cts.IProjection; |
|
28 |
|
|
29 |
import org.cresques.geo.Projected; |
|
30 |
import org.cresques.px.Extent; |
|
31 |
|
|
32 |
|
|
33 |
import java.awt.geom.Point2D; |
|
34 |
|
|
35 |
import java.io.InputStream; |
|
36 |
import java.io.OutputStream; |
|
37 |
|
|
38 |
import java.util.Vector; |
|
39 |
|
|
40 |
|
|
41 |
/** |
|
42 |
* @author Luis W. Sevilla <sevilla_lui@gva.es> |
|
43 |
*/ |
|
44 |
public class Hoja implements Projected { |
|
45 |
IProjection proj; |
|
46 |
String code = null; |
|
47 |
String name = null; |
|
48 |
Extent extent = null; |
|
49 |
Point2D tl; |
|
50 |
Point2D tr; |
|
51 |
Point2D bl; |
|
52 |
Point2D br; |
|
53 |
|
|
54 |
public Hoja(IProjection proj, String code, String name) { |
|
55 |
this.proj = proj; |
|
56 |
this.code = code; |
|
57 |
this.name = name; |
|
58 |
tl = tr = bl = br = null; |
|
59 |
} |
|
60 |
|
|
61 |
public Hoja(String cod, Point2D p1, Point2D p2, Point2D p3, Point2D p4, |
|
62 |
String name) { |
|
63 |
code = cod; |
|
64 |
tl = p1; |
|
65 |
tr = p2; |
|
66 |
bl = p3; |
|
67 |
br = p4; |
|
68 |
|
|
69 |
if (name != null) { |
|
70 |
this.name = name; |
|
71 |
} |
|
72 |
|
|
73 |
setExtent(); |
|
74 |
} |
|
75 |
|
|
76 |
public Hoja(String cod, Point2D[] pt, String name) { |
|
77 |
code = cod; |
|
78 |
tl = pt[0]; |
|
79 |
tr = pt[1]; |
|
80 |
br = pt[2]; |
|
81 |
bl = pt[3]; |
|
82 |
|
|
83 |
if (name != null) { |
|
84 |
this.name = name; |
|
85 |
} |
|
86 |
|
|
87 |
setExtent(); |
|
88 |
} |
|
89 |
|
|
90 |
public Hoja(String cod, Vector pt, String name) { |
|
91 |
code = cod; |
|
92 |
tl = (Point2D) pt.get(0); |
|
93 |
tr = (Point2D) pt.get(1); |
|
94 |
br = (Point2D) pt.get(2); |
|
95 |
bl = (Point2D) pt.get(3); |
|
96 |
|
|
97 |
if (name != null) { |
|
98 |
this.name = name; |
|
99 |
} |
|
100 |
|
|
101 |
setExtent(); |
|
102 |
} |
|
103 |
|
|
104 |
public Hoja(String cod, Hoja h, String name) { |
|
105 |
code = cod; |
|
106 |
tl = h.tl; |
|
107 |
tr = h.tr; |
|
108 |
br = h.br; |
|
109 |
bl = h.bl; |
|
110 |
|
|
111 |
if (name != null) { |
|
112 |
this.name = name; |
|
113 |
} |
|
114 |
|
|
115 |
setExtent(); |
|
116 |
} |
|
117 |
|
|
118 |
public IProjection getProjection() { |
|
119 |
return proj; |
|
120 |
} |
|
121 |
|
|
122 |
public void setProjection(IProjection p) { |
|
123 |
proj = p; |
|
124 |
} |
|
125 |
|
|
126 |
public void reProject(ICoordTrans rp) { |
|
127 |
// TODO metodo reProject pendiente de implementar |
|
128 |
} |
|
129 |
|
|
130 |
public Point2D getTL() { |
|
131 |
return tl; |
|
132 |
} |
|
133 |
|
|
134 |
public void setTL(Point2D pt) { |
|
135 |
tl = pt; |
|
136 |
extent.add(pt); |
|
137 |
} |
|
138 |
|
|
139 |
public Point2D getTR() { |
|
140 |
return tr; |
|
141 |
} |
|
142 |
|
|
143 |
public void setTR(Point2D pt) { |
|
144 |
tr = pt; |
|
145 |
extent.add(pt); |
|
146 |
} |
|
147 |
|
|
148 |
public Point2D getBL() { |
|
149 |
return bl; |
|
150 |
} |
|
151 |
|
|
152 |
public void setBL(Point2D pt) { |
|
153 |
bl = pt; |
|
154 |
extent.add(pt); |
|
155 |
} |
|
156 |
|
|
157 |
public Point2D getBR() { |
|
158 |
return br; |
|
159 |
} |
|
160 |
|
|
161 |
public void setBR(Point2D pt) { |
|
162 |
br = pt; |
|
163 |
extent.add(pt); |
|
164 |
} |
|
165 |
|
|
166 |
public Extent getExtent() { |
|
167 |
return extent; |
|
168 |
} |
|
169 |
|
|
170 |
private void setExtent() { |
|
171 |
extent = new Extent(tl, br); |
|
172 |
extent.add(tr); |
|
173 |
extent.add(bl); |
|
174 |
} |
|
175 |
|
|
176 |
public String getCode() { |
|
177 |
return code; |
|
178 |
} |
|
179 |
|
|
180 |
public String getName() { |
|
181 |
return name; |
|
182 |
} |
|
183 |
|
|
184 |
public Point2D[] getVertex() { |
|
185 |
Point2D[] v = { tl, tr, br, bl }; |
|
186 |
|
|
187 |
return v; |
|
188 |
} |
|
189 |
|
|
190 |
public void toXml(OutputStream os) { |
|
191 |
} |
|
192 |
|
|
193 |
public void fromXml(InputStream is) { |
|
194 |
} |
|
195 |
} |
org.gvsig.dxf/tags/org.gvsig.dxf-2.0.91/org.gvsig.dxf.lib/src/main/java/org/gvsig/dxf/geo/cover/package.html | ||
---|---|---|
1 |
<html> |
|
2 |
<body>Clases relacionadas con coverturas espaciales. |
|
3 |
</body> |
|
4 |
</html> |
org.gvsig.dxf/tags/org.gvsig.dxf-2.0.91/org.gvsig.dxf.lib/src/main/java/org/gvsig/dxf/geo/Point3D.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.geo; |
|
25 |
|
|
26 |
import java.awt.geom.Point2D; |
|
27 |
|
|
28 |
|
|
29 |
/** |
|
30 |
* @author "Luis W. Sevilla" <sevilla_lui@gva.es> |
|
31 |
*/ |
|
32 |
public class Point3D extends Point2D { |
|
33 |
public double X; |
|
34 |
public double Y; |
|
35 |
public double Z; |
|
36 |
|
|
37 |
public Point3D() { |
|
38 |
setLocation(0.0, 0.0); |
|
39 |
} |
|
40 |
|
|
41 |
public Point3D(double x, double y) { |
|
42 |
setLocation(x, y); |
|
43 |
} |
|
44 |
|
|
45 |
public Point3D(double x, double y, double z) { |
|
46 |
setLocation(x, y, z); |
|
47 |
} |
|
48 |
|
|
49 |
public Point3D(Point2D pt) { |
|
50 |
setLocation(pt.getX(), pt.getY()); |
|
51 |
} |
|
52 |
|
|
53 |
public Point3D(Point3D pt) { |
|
54 |
setLocation(pt.getX(), pt.getY(), pt.getZ()); |
|
55 |
} |
|
56 |
|
|
57 |
public double getX() { |
|
58 |
return X; |
|
59 |
} |
|
60 |
|
|
61 |
public double getY() { |
|
62 |
return Y; |
|
63 |
} |
|
64 |
|
|
65 |
public double getZ() { |
|
66 |
return Z; |
|
67 |
} |
|
68 |
|
|
69 |
public void setLocation(double x, double y) { |
|
70 |
X = x; |
|
71 |
Y = y; |
|
72 |
Z = 0D; |
|
73 |
} |
|
74 |
|
|
75 |
public void setLocation(double x, double y, double z) { |
|
76 |
X = x; |
|
77 |
Y = y; |
|
78 |
Z = z; |
|
79 |
} |
|
80 |
|
|
81 |
public String toString() { |
|
82 |
return "(" + getX() + "," + getY() + ")"; |
|
83 |
} |
|
84 |
} |
org.gvsig.dxf/tags/org.gvsig.dxf-2.0.91/org.gvsig.dxf.lib/src/main/java/org/gvsig/dxf/io/DataSource.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.util.Hashtable; |
|
27 |
|
|
28 |
|
|
29 |
/** |
|
30 |
* Origen de datos. Unidad, volumen de red, etc. |
|
31 |
* |
|
32 |
* @author "Luis W. Sevilla" <sevilla_lui@gva.es> |
|
33 |
*/ |
|
34 |
public class DataSource { |
|
35 |
private static int counter = 0; |
|
36 |
private static Hashtable units = new Hashtable(); |
|
37 |
String path = null; |
|
38 |
String name = null; |
|
39 |
|
|
40 |
public DataSource(String path, String name) { |
|
41 |
this.path = path; |
|
42 |
this.name = name; |
|
43 |
units.put(name, this); |
|
44 |
} |
|
45 |
|
|
46 |
public String getName() { |
|
47 |
return name; |
|
48 |
} |
|
49 |
|
|
50 |
public String getPath() { |
|
51 |
return path; |
|
52 |
} |
|
53 |
|
|
54 |
public static DataSource getDSFromName(String name) { |
|
55 |
if (name.indexOf("[") >= 0) { |
|
56 |
name = name.substring(name.indexOf("[") + 1); |
|
57 |
} |
|
58 |
|
|
59 |
if (name.indexOf("]") >= 0) { |
|
60 |
name = name.substring(0, name.indexOf("]")); |
|
61 |
} |
|
62 |
|
|
63 |
DataSource ds = (DataSource) units.get(name); |
|
64 |
|
|
65 |
return ds; |
|
66 |
} |
|
67 |
|
|
68 |
/** |
|
69 |
* Sustituye en el path el nombre de la unidad por su path real. |
|
70 |
* |
|
71 |
* @param path |
|
72 |
* @return |
|
73 |
*/ |
|
74 |
public static String normalize(String path) { |
|
75 |
if (path.indexOf("[") >= 0) { |
|
76 |
DataSource ds = DataSource.getDSFromName(path); |
|
77 |
|
|
78 |
if (ds == null) { |
|
79 |
return null; |
|
80 |
} |
|
81 |
|
|
82 |
path = path.substring(0, path.indexOf("[")) + ds.getPath() + |
|
83 |
path.substring(path.indexOf("]") + 1); |
|
84 |
|
|
85 |
} |
|
86 |
|
|
87 |
return path; |
|
88 |
} |
|
89 |
|
|
90 |
public String toString() { |
|
91 |
return "[" + counter + "]"; |
|
92 |
} |
|
93 |
} |
org.gvsig.dxf/tags/org.gvsig.dxf-2.0.91/org.gvsig.dxf.lib/src/main/java/org/gvsig/dxf/io/GeoFile.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.awt.geom.AffineTransform; |
|
27 |
import java.util.Date; |
|
28 |
|
|
29 |
import org.cresques.cts.ICoordTrans; |
|
30 |
import org.cresques.cts.IProjection; |
|
31 |
import org.cresques.geo.Projected; |
|
32 |
import org.cresques.px.Extent; |
|
33 |
import org.gvsig.dxf.px.IObjList; |
|
34 |
|
|
35 |
|
|
36 |
/** |
|
37 |
* Ancestro de todos los formatos geogr?ficos |
|
38 |
* |
|
39 |
* @author "Luis W. Sevilla" <sevilla_lui@gva.es>* @author administrador |
|
40 |
*/ |
|
41 |
public abstract class GeoFile implements Projected, Extent.Has { |
|
42 |
IProjection proj = null; |
|
43 |
/** |
|
44 |
* Extent completo del raster. Este contiene las coordenadas reales tanto |
|
45 |
* para un raster rotado como sin rotar. Este extent coincide con requestExtent |
|
46 |
* cuando el raster no tiene rotaci?n. |
|
47 |
*/ |
|
48 |
protected Extent extent = null; |
|
49 |
/** |
|
50 |
* Este es el extent sobre el que se ajusta una petici?n para que esta no exceda el |
|
51 |
* extent m?ximo del raster. Para un raster sin rotar ser? igual al extent |
|
52 |
* pero para un raster rotado ser? igual al extent del raster como si no |
|
53 |
* tuviera rotaci?n. Esto ha de ser as? ya que la rotaci?n solo se hace sobre la |
|
54 |
* vista y las peticiones han de hacerse en coordenadas de la imagen sin shearing |
|
55 |
* aplicado. |
|
56 |
*/ |
|
57 |
protected Extent requestExtent = null; |
|
58 |
/** |
|
59 |
* Esto corresponde a la transformaci?n del extent de la imagen. Se calcula a partir del extent |
|
60 |
* guardado en el fichero .rmf asociado a la imagen. En caso de que no exista este fichero no habr? |
|
61 |
* transformaci?n |
|
62 |
*/ |
|
63 |
protected AffineTransform transformRMF = null; |
|
64 |
/** |
|
65 |
* Esto corresponde a la transformaci?n del extent de la imagen. Se calcula a partir del extent |
|
66 |
* guardado en el fichero .tfw asociado a la imagen o en la cabecera de la misma. |
|
67 |
*/ |
|
68 |
protected AffineTransform transformTFW = null; |
|
69 |
|
|
70 |
|
|
71 |
protected boolean rmfExists = false; |
|
72 |
long fileSize = 0; |
|
73 |
protected long bytesReaded = 0; |
|
74 |
protected long lineCnt = 0; |
|
75 |
String name; |
|
76 |
|
|
77 |
public GeoFile() { |
|
78 |
} |
|
79 |
|
|
80 |
public GeoFile(IProjection p, String n) { |
|
81 |
proj = p; |
|
82 |
name = n; |
|
83 |
|
|
84 |
if (name != null) { |
|
85 |
name = DataSource.normalize(name); |
|
86 |
} |
|
87 |
extent = new Extent(); |
|
88 |
transformRMF = new AffineTransform(); |
|
89 |
transformTFW = new AffineTransform(); |
|
90 |
} |
|
91 |
|
|
92 |
public String getName() { |
|
93 |
return name; |
|
94 |
} |
|
95 |
|
|
96 |
public void setName(String n) { |
|
97 |
name = n; |
|
98 |
} |
|
99 |
|
|
100 |
public long getFileSize() { |
|
101 |
return fileSize; |
|
102 |
} |
|
103 |
|
|
104 |
public void setFileSize(long sz) { |
|
105 |
fileSize = sz; |
|
106 |
} |
|
107 |
|
|
108 |
public IProjection getProjection() { |
|
109 |
return proj; |
|
110 |
} |
|
111 |
|
|
112 |
public void setProjection(IProjection p) { |
|
113 |
proj = p; |
|
114 |
} |
|
115 |
|
|
116 |
abstract public void reProject(ICoordTrans rp); |
|
117 |
|
|
118 |
/** |
|
119 |
* Extent completo del raster. Este contiene las coordenadas reales tanto |
|
120 |
* para un raster rotado como sin rotar. Este extent coincide con requestExtent |
|
121 |
* cuando el raster no tiene rotaci?n. |
|
122 |
* @return Extent |
|
123 |
*/ |
|
124 |
public Extent getExtent() { |
|
125 |
return extent; |
|
126 |
} |
|
127 |
|
|
128 |
/** |
|
129 |
* Este es el extent sobre el que se ajusta una petici?n para que esta no exceda el |
|
130 |
* extent m?ximo del raster. Para un raster sin rotar ser? igual al extent |
|
131 |
* pero para un raster rotado ser? igual al extent del raster como si no |
|
132 |
* tuviera rotaci?n. Esto ha de ser as? ya que la rotaci?n solo se hace sobre la |
|
133 |
* vista y las peticiones han de hacerse en coordenadas de la imagen sin shearing |
|
134 |
* aplicado. |
|
135 |
* @return Extent |
|
136 |
*/ |
|
137 |
public Extent getExtentForRequest() { |
|
138 |
return requestExtent; |
|
139 |
} |
|
140 |
|
|
141 |
abstract public GeoFile load() throws Exception; |
|
142 |
|
|
143 |
abstract public void close(); |
|
144 |
|
|
145 |
abstract public IObjList getObjects(); |
|
146 |
|
|
147 |
/** |
|
148 |
* Filtra espacios en blanco. Deja solo uno por |
|
149 |
*/ |
|
150 |
public static String filterWS(String buf) { |
|
151 |
boolean lastCharWhite = false; |
|
152 |
String str = ""; |
|
153 |
buf = buf.trim(); |
|
154 |
|
|
155 |
for (int i = 0; i < buf.length(); i++) { |
|
156 |
char c = buf.charAt(i); |
|
157 |
|
|
158 |
if (Character.isWhitespace(c)) { |
|
159 |
if (lastCharWhite) { |
|
160 |
continue; |
|
161 |
} |
|
162 |
|
|
163 |
lastCharWhite = true; |
|
164 |
c = ' '; |
|
165 |
} else { |
|
166 |
lastCharWhite = false; |
|
167 |
} |
|
168 |
|
|
169 |
str += c; |
|
170 |
} |
|
171 |
|
|
172 |
return str; |
|
173 |
} |
|
174 |
|
|
175 |
protected long getTime() { |
|
176 |
return (new Date()).getTime(); |
|
177 |
} |
|
178 |
} |
org.gvsig.dxf/tags/org.gvsig.dxf-2.0.91/org.gvsig.dxf.lib/src/main/java/org/gvsig/dxf/io/FileFolder.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 |
|
|
27 |
/** |
|
28 |
* |
|
29 |
* @author "Luis W. Sevilla" <sevilla_lui@gva.es>* @author administrador |
|
30 |
*/ |
|
31 |
abstract public class FileFolder { |
|
32 |
static String[] supportedFolders = { "zip://" }; |
|
33 |
|
|
34 |
abstract public int count(); |
|
35 |
|
|
36 |
/** |
|
37 |
* Analiza un nombre de fichero en formato zip://zipname.zip?file.ext |
|
38 |
* @param urlName |
|
39 |
*/ |
|
40 |
public static boolean isUrl(String name) { |
|
41 |
String str = name.substring(0, 6); |
|
42 |
str.toLowerCase(); |
|
43 |
|
|
44 |
for (int i = 0; i < supportedFolders.length; i++) |
|
45 |
if (str.compareTo(supportedFolders[i]) == 0) { |
|
46 |
return true; |
|
47 |
} |
|
48 |
|
|
49 |
return false; |
|
50 |
} |
|
51 |
} |
org.gvsig.dxf/tags/org.gvsig.dxf-2.0.91/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) { |
Also available in: Unified diff