Revision 311
tags/org.gvsig.app.document.layout2.app-2.0.40/pom.xml | ||
---|---|---|
1 |
<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"> |
|
2 |
|
|
3 |
<modelVersion>4.0.0</modelVersion> |
|
4 |
<artifactId>org.gvsig.app.document.layout2.app</artifactId> |
|
5 |
<packaging>pom</packaging> |
|
6 |
<version>2.0.40</version> |
|
7 |
|
|
8 |
<name>Document: Layout document v2, parent artifact</name> |
|
9 |
<description>This plugin adds creation/management of layout (map) documents.</description> |
|
10 |
|
|
11 |
<parent> |
|
12 |
<groupId>org.gvsig</groupId> |
|
13 |
<artifactId>org.gvsig.desktop</artifactId> |
|
14 |
<version>2.0.57</version> |
|
15 |
</parent> |
|
16 |
|
|
17 |
<url>https://devel.gvsig.org/redmine/projects/gvsig-app-document-layout</url> |
|
18 |
|
|
19 |
<scm> |
|
20 |
<connection>scm:svn:https://devel.gvsig.org/svn/gvsig-app-document-layout/tags/org.gvsig.app.document.layout2.app-2.0.40</connection> |
|
21 |
<developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-app-document-layout/tags/org.gvsig.app.document.layout2.app-2.0.40</developerConnection> |
|
22 |
<url>https://devel.gvsig.org/redmine/projects/gvsig-app-document-layout/repository/show/tags/org.gvsig.app.document.layout2.app-2.0.40</url> |
|
23 |
</scm> |
|
24 |
<repositories> |
|
25 |
<repository> |
|
26 |
<id>gvsig-public-http-repository</id> |
|
27 |
<name>gvSIG maven public HTTP repository</name> |
|
28 |
<url>http://devel.gvsig.org/m2repo/j2se</url> |
|
29 |
<releases> |
|
30 |
<enabled>true</enabled> |
|
31 |
<updatePolicy>daily</updatePolicy> |
|
32 |
<checksumPolicy>warn</checksumPolicy> |
|
33 |
</releases> |
|
34 |
<snapshots> |
|
35 |
<enabled>true</enabled> |
|
36 |
<updatePolicy>daily</updatePolicy> |
|
37 |
<checksumPolicy>warn</checksumPolicy> |
|
38 |
</snapshots> |
|
39 |
</repository> |
|
40 |
</repositories> |
|
41 |
|
|
42 |
<build> |
|
43 |
<plugins> |
|
44 |
<plugin> |
|
45 |
<groupId>org.apache.maven.plugins</groupId> |
|
46 |
<artifactId>maven-release-plugin</artifactId> |
|
47 |
<configuration> |
|
48 |
<tagBase>https://devel.gvsig.org/svn/gvsig-app-document-layout/tags</tagBase> |
|
49 |
</configuration> |
|
50 |
</plugin> |
|
51 |
</plugins> |
|
52 |
</build> |
|
53 |
|
|
54 |
<modules> |
|
55 |
<module>org.gvsig.app.document.layout2.app.mainplugin</module> |
|
56 |
</modules> |
|
57 |
|
|
58 |
</project> |
tags/org.gvsig.app.document.layout2.app-2.0.40/org.gvsig.app.document.layout2.app.mainplugin/src/test/resources/README.txt | ||
---|---|---|
1 |
Put into this folder the resources needed by your test classes. |
|
2 |
|
|
3 |
This folder is added to the Tests classpath, so you can load any resources |
|
4 |
through the ClassLoader. |
|
5 |
|
|
6 |
By default, in this folder you can find an example of log4j configuration, |
|
7 |
prepared to log messages through the console, so logging works when you |
|
8 |
run your tests classes. |
tags/org.gvsig.app.document.layout2.app-2.0.40/org.gvsig.app.document.layout2.app.mainplugin/src/test/resources/log4j.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1" ?> |
|
2 |
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> |
|
3 |
|
|
4 |
<!-- |
|
5 |
Log4J configuration file for unit tests execution. |
|
6 |
--> |
|
7 |
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> |
|
8 |
|
|
9 |
<!-- Appender configuration to show logging messages through the console --> |
|
10 |
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender"> |
|
11 |
<layout class="org.apache.log4j.PatternLayout"> |
|
12 |
<param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p [%c{2}.%M()]\n %m%n" /> |
|
13 |
</layout> |
|
14 |
</appender> |
|
15 |
|
|
16 |
<!-- |
|
17 |
Activate logging messages of DEBUG level of higher only for the |
|
18 |
org.gvsig.tools packages. |
|
19 |
You can put full classes names or packages instead, to configure |
|
20 |
logging for all the classes and subpackages of the package. |
|
21 |
--> |
|
22 |
<category name="org.gvsig.tools"> |
|
23 |
<priority value="DEBUG" /> |
|
24 |
</category> |
|
25 |
<category name="org.gvsig.app.document.layout"> |
|
26 |
<priority value="DEBUG" /> |
|
27 |
</category> |
|
28 |
|
|
29 |
<!-- |
|
30 |
By default, show only logging messages of INFO level or higher, |
|
31 |
through the previously configured CONSOLE appender. |
|
32 |
--> |
|
33 |
<root> |
|
34 |
<priority value="INFO" /> |
|
35 |
<appender-ref ref="CONSOLE" /> |
|
36 |
</root> |
|
37 |
</log4j:configuration> |
|
0 | 38 |
tags/org.gvsig.app.document.layout2.app-2.0.40/org.gvsig.app.document.layout2.app.mainplugin/src/main/assembly/gvsig-plugin-package.xml | ||
---|---|---|
1 |
<assembly> |
|
2 |
<id>gvsig-plugin-package</id> |
|
3 |
<formats> |
|
4 |
<format>zip</format> |
|
5 |
</formats> |
|
6 |
<baseDirectory>${project.artifactId}</baseDirectory> |
|
7 |
<includeBaseDirectory>true</includeBaseDirectory> |
|
8 |
<files> |
|
9 |
<file> |
|
10 |
<source>target/${project.artifactId}-${project.version}.jar</source> |
|
11 |
<outputDirectory>lib</outputDirectory> |
|
12 |
</file> |
|
13 |
<file> |
|
14 |
<source>target/package.info</source> |
|
15 |
</file> |
|
16 |
</files> |
|
17 |
|
|
18 |
<fileSets> |
|
19 |
<fileSet> |
|
20 |
<directory>src/main/resources-plugin</directory> |
|
21 |
<outputDirectory>.</outputDirectory> |
|
22 |
</fileSet> |
|
23 |
</fileSets> |
|
24 |
|
|
25 |
<dependencySets> |
|
26 |
|
|
27 |
<!-- |
|
28 |
<dependencySet> |
|
29 |
<useProjectArtifact>false</useProjectArtifact> |
|
30 |
<useTransitiveDependencies>false</useTransitiveDependencies> |
|
31 |
<outputDirectory>lib</outputDirectory> |
|
32 |
<includes> |
|
33 |
</includes> |
|
34 |
</dependencySet> |
|
35 |
|
|
36 |
--> |
|
37 |
|
|
38 |
</dependencySets> |
|
39 |
|
|
40 |
</assembly> |
|
0 | 41 |
tags/org.gvsig.app.document.layout2.app-2.0.40/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/geometryadapters/RectangleAdapter.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.app.project.documents.layout.geometryadapters; |
|
23 |
|
|
24 |
import java.awt.geom.Point2D; |
|
25 |
|
|
26 |
import org.slf4j.Logger; |
|
27 |
import org.slf4j.LoggerFactory; |
|
28 |
|
|
29 |
import org.gvsig.fmap.geom.Geometry.SUBTYPES; |
|
30 |
import org.gvsig.fmap.geom.Geometry.TYPES; |
|
31 |
import org.gvsig.fmap.geom.exception.CreateGeometryException; |
|
32 |
import org.gvsig.fmap.geom.primitive.Surface; |
|
33 |
import org.gvsig.tools.ToolsLocator; |
|
34 |
import org.gvsig.tools.dynobject.DynStruct; |
|
35 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
36 |
|
|
37 |
/** |
|
38 |
* DOCUMENT ME! |
|
39 |
* |
|
40 |
* @author Vicente Caballero Navarro |
|
41 |
*/ |
|
42 |
public class RectangleAdapter extends PolygonAdapter { |
|
43 |
|
|
44 |
public static final String PERSISTENCE_DEFINITION_NAME = "RectangleAdapter"; |
|
45 |
private static final Logger logger = LoggerFactory.getLogger(RectangleAdapter.class); |
|
46 |
|
|
47 |
public RectangleAdapter() { |
|
48 |
super(); |
|
49 |
} |
|
50 |
|
|
51 |
/** |
|
52 |
* DOCUMENT ME! |
|
53 |
* |
|
54 |
* @param p |
|
55 |
* DOCUMENT ME! |
|
56 |
*/ |
|
57 |
public void obtainShape(Point2D p) { |
|
58 |
Point2D[] points = getPoints(); |
|
59 |
|
|
60 |
try { |
|
61 |
Surface surface = (Surface)geomManager.create(TYPES.SURFACE, SUBTYPES.GEOM2D); |
|
62 |
if (points.length > 0) { |
|
63 |
surface.addMoveToVertex(geomManager.createPoint(points[0].getX(), points[0].getY(), SUBTYPES.GEOM2D)); |
|
64 |
} |
|
65 |
if (points.length > 0) { |
|
66 |
surface.addVertex(geomManager.createPoint(p.getX(), points[0].getY(), SUBTYPES.GEOM2D)); |
|
67 |
surface.addVertex(geomManager.createPoint(p.getX(), p.getY(), SUBTYPES.GEOM2D)); |
|
68 |
surface.addVertex(geomManager.createPoint(points[0].getX(), p.getY(), SUBTYPES.GEOM2D)); |
|
69 |
surface.addVertex(geomManager.createPoint(points[0].getX(), points[0].getY(), SUBTYPES.GEOM2D)); |
|
70 |
} |
|
71 |
|
|
72 |
setGeometry(surface); |
|
73 |
} catch (CreateGeometryException e) { |
|
74 |
logger.error("Error creating the circle", e); |
|
75 |
} |
|
76 |
} |
|
77 |
|
|
78 |
public static void registerPersistent() { |
|
79 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
|
80 |
if (manager.getDefinition(PERSISTENCE_DEFINITION_NAME) == null) { |
|
81 |
DynStruct definition = |
|
82 |
manager.addDefinition(RectangleAdapter.class, |
|
83 |
PERSISTENCE_DEFINITION_NAME, |
|
84 |
"Recangle Adapter persistence definition", null, null); |
|
85 |
|
|
86 |
definition.extend(manager |
|
87 |
.getDefinition(GeometryAdapter.PERSISTENCE_DEFINITION_NAME)); |
|
88 |
} |
|
89 |
} |
|
90 |
} |
tags/org.gvsig.app.document.layout2.app-2.0.40/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/geometryadapters/PolygonAdapter.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.app.project.documents.layout.geometryadapters; |
|
23 |
|
|
24 |
import java.awt.geom.Point2D; |
|
25 |
|
|
26 |
import org.slf4j.Logger; |
|
27 |
import org.slf4j.LoggerFactory; |
|
28 |
|
|
29 |
import org.gvsig.fmap.geom.Geometry.SUBTYPES; |
|
30 |
import org.gvsig.fmap.geom.Geometry.TYPES; |
|
31 |
import org.gvsig.fmap.geom.exception.CreateGeometryException; |
|
32 |
import org.gvsig.fmap.geom.primitive.Surface; |
|
33 |
import org.gvsig.tools.ToolsLocator; |
|
34 |
import org.gvsig.tools.dynobject.DynStruct; |
|
35 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
36 |
|
|
37 |
/** |
|
38 |
* DOCUMENT ME! |
|
39 |
* |
|
40 |
* @author Vicente Caballero Navarro |
|
41 |
*/ |
|
42 |
public class PolygonAdapter extends PolyLineAdapter { |
|
43 |
|
|
44 |
public static final String PERSISTENCE_DEFINITION_NAME = "PolygonAdapter"; |
|
45 |
private static final Logger logger = LoggerFactory |
|
46 |
.getLogger(PolygonAdapter.class); |
|
47 |
|
|
48 |
public PolygonAdapter() { |
|
49 |
super(); |
|
50 |
} |
|
51 |
|
|
52 |
/** |
|
53 |
* DOCUMENT ME! |
|
54 |
* |
|
55 |
* @param p |
|
56 |
* DOCUMENT ME! |
|
57 |
*/ |
|
58 |
public void obtainShape(Point2D p) { |
|
59 |
Point2D[] points = getPoints(); |
|
60 |
|
|
61 |
try { |
|
62 |
Surface surface = (Surface)geomManager.create(TYPES.SURFACE, SUBTYPES.GEOM2D); |
|
63 |
if (points.length > 0) { |
|
64 |
surface.addMoveToVertex(geomManager.createPoint(points[0].getX(), points[0].getY(), SUBTYPES.GEOM2D)); |
|
65 |
} |
|
66 |
for (int i = 1; i < points.length; i++) { |
|
67 |
surface.addVertex(geomManager.createPoint(points[i].getX(), points[i].getY(), SUBTYPES.GEOM2D)); |
|
68 |
} |
|
69 |
if (points.length > 0) { |
|
70 |
surface.addVertex(geomManager.createPoint(p.getX(), p.getY(), SUBTYPES.GEOM2D)); |
|
71 |
surface.addVertex(geomManager.createPoint(points[0].getX(), points[0].getY(), SUBTYPES.GEOM2D)); |
|
72 |
} |
|
73 |
|
|
74 |
setGeometry(surface); |
|
75 |
} catch (CreateGeometryException e) { |
|
76 |
logger.error("Error creating the circle", e); |
|
77 |
} |
|
78 |
} |
|
79 |
|
|
80 |
public static void registerPersistent() { |
|
81 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
|
82 |
if (manager.getDefinition(PERSISTENCE_DEFINITION_NAME) == null) { |
|
83 |
DynStruct definition = |
|
84 |
manager.addDefinition(PolygonAdapter.class, |
|
85 |
PERSISTENCE_DEFINITION_NAME, |
|
86 |
"Polygon Adapter persistence definition", null, null); |
|
87 |
|
|
88 |
definition.extend(manager |
|
89 |
.getDefinition(GeometryAdapter.PERSISTENCE_DEFINITION_NAME)); |
|
90 |
} |
|
91 |
} |
|
92 |
} |
tags/org.gvsig.app.document.layout2.app-2.0.40/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/geometryadapters/PointAdapter.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.app.project.documents.layout.geometryadapters; |
|
23 |
|
|
24 |
import java.awt.Graphics2D; |
|
25 |
import java.awt.geom.AffineTransform; |
|
26 |
import java.awt.geom.Point2D; |
|
27 |
import java.awt.geom.Rectangle2D; |
|
28 |
|
|
29 |
import org.slf4j.Logger; |
|
30 |
import org.slf4j.LoggerFactory; |
|
31 |
|
|
32 |
import org.gvsig.fmap.geom.Geometry.SUBTYPES; |
|
33 |
import org.gvsig.fmap.geom.exception.CreateGeometryException; |
|
34 |
import org.gvsig.fmap.geom.primitive.Point; |
|
35 |
import org.gvsig.tools.ToolsLocator; |
|
36 |
import org.gvsig.tools.dynobject.DynStruct; |
|
37 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
38 |
|
|
39 |
/** |
|
40 |
* DOCUMENT ME! |
|
41 |
* |
|
42 |
* @author Vicente Caballero Navarro |
|
43 |
*/ |
|
44 |
public class PointAdapter extends PolyLineAdapter { |
|
45 |
|
|
46 |
public static final String PERSISTENCE_DEFINITION_NAME = "PointAdapter"; |
|
47 |
private static final Logger logger = LoggerFactory |
|
48 |
.getLogger(PointAdapter.class); |
|
49 |
|
|
50 |
public PointAdapter() { |
|
51 |
super(); |
|
52 |
} |
|
53 |
|
|
54 |
public void paint(Graphics2D g, AffineTransform at, boolean andLastPoint) { |
|
55 |
|
|
56 |
} |
|
57 |
|
|
58 |
public void obtainShape(Point2D p) { |
|
59 |
try { |
|
60 |
Point point = geomManager.createPoint(p.getX(), p.getY(), SUBTYPES.GEOM2D); |
|
61 |
setGeometry(point); |
|
62 |
} catch (CreateGeometryException e) { |
|
63 |
logger.error("Error creating a point", e); |
|
64 |
} |
|
65 |
} |
|
66 |
|
|
67 |
public Rectangle2D getBounds2D() { |
|
68 |
Rectangle2D r = getGeometry(new AffineTransform()).getBounds2D(); |
|
69 |
double w = r.getWidth(); |
|
70 |
double h = r.getHeight(); |
|
71 |
double x = r.getX(); |
|
72 |
double y = r.getY(); |
|
73 |
boolean modified = false; |
|
74 |
if (r.getWidth() < 0.5) { |
|
75 |
modified = true; |
|
76 |
w = 1; |
|
77 |
x = x - 0.25; |
|
78 |
} |
|
79 |
if (r.getHeight() < 0.5) { |
|
80 |
modified = true; |
|
81 |
h = 1; |
|
82 |
// y=y-0.5; |
|
83 |
} |
|
84 |
if (modified) { |
|
85 |
return new Rectangle2D.Double(x, y, w, h); |
|
86 |
} |
|
87 |
return r; |
|
88 |
} |
|
89 |
|
|
90 |
public static void registerPersistent() { |
|
91 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
|
92 |
if (manager.getDefinition(PERSISTENCE_DEFINITION_NAME) == null) { |
|
93 |
DynStruct definition = |
|
94 |
manager.addDefinition(PointAdapter.class, |
|
95 |
PERSISTENCE_DEFINITION_NAME, |
|
96 |
"Point Adapter persistence definition", null, null); |
|
97 |
|
|
98 |
definition.extend(manager |
|
99 |
.getDefinition(GeometryAdapter.PERSISTENCE_DEFINITION_NAME)); |
|
100 |
} |
|
101 |
} |
|
102 |
} |
tags/org.gvsig.app.document.layout2.app-2.0.40/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/geometryadapters/GeometryAdapter.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
package org.gvsig.app.project.documents.layout.geometryadapters; |
|
42 |
|
|
43 |
import java.awt.Graphics2D; |
|
44 |
import java.awt.geom.AffineTransform; |
|
45 |
import java.awt.geom.Arc2D; |
|
46 |
import java.awt.geom.FlatteningPathIterator; |
|
47 |
import java.awt.geom.NoninvertibleTransformException; |
|
48 |
import java.awt.geom.Point2D; |
|
49 |
import java.awt.geom.Rectangle2D; |
|
50 |
import java.util.ArrayList; |
|
51 |
import java.util.Collections; |
|
52 |
import java.util.List; |
|
53 |
|
|
54 |
import org.gvsig.compat.print.PrintAttributes; |
|
55 |
import org.gvsig.fmap.geom.Geometry; |
|
56 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
57 |
import org.gvsig.fmap.geom.GeometryManager; |
|
58 |
import org.gvsig.fmap.geom.Geometry.SUBTYPES; |
|
59 |
import org.gvsig.fmap.geom.Geometry.TYPES; |
|
60 |
import org.gvsig.fmap.geom.exception.CreateGeometryException; |
|
61 |
import org.gvsig.fmap.geom.primitive.Circle; |
|
62 |
import org.gvsig.fmap.geom.primitive.GeneralPathX; |
|
63 |
import org.gvsig.fmap.geom.primitive.Point; |
|
64 |
import org.gvsig.fmap.geom.type.GeometryTypeNotSupportedException; |
|
65 |
import org.gvsig.fmap.geom.type.GeometryTypeNotValidException; |
|
66 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
|
67 |
import org.gvsig.tools.ToolsLocator; |
|
68 |
import org.gvsig.tools.dynobject.DynStruct; |
|
69 |
import org.gvsig.tools.lang.Cloneable; |
|
70 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
71 |
import org.gvsig.tools.persistence.Persistent; |
|
72 |
import org.gvsig.tools.persistence.PersistentState; |
|
73 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
|
74 |
import org.gvsig.app.project.documents.layout.geometryadapters.PrintingCircle2D; |
|
75 |
|
|
76 |
/** |
|
77 |
* Abstract adaptor to relate the geometries with the fframes and to be able to |
|
78 |
* integrate them in the Layout. |
|
79 |
* |
|
80 |
* @author Vicente Caballero Navarro |
|
81 |
*/ |
|
82 |
public abstract class GeometryAdapter implements Persistent, Cloneable { |
|
83 |
|
|
84 |
public static final String PERSISTENCE_DEFINITION_NAME = "GeometryAdapter"; |
|
85 |
|
|
86 |
private static final String POINTS_FIELD = "points"; |
|
87 |
|
|
88 |
protected static final GeometryManager geomManager = GeometryLocator.getGeometryManager(); |
|
89 |
|
|
90 |
private List<Point2D> points = new ArrayList<Point2D>(); |
|
91 |
private Geometry geometry; |
|
92 |
|
|
93 |
public GeometryAdapter() { |
|
94 |
super(); |
|
95 |
} |
|
96 |
|
|
97 |
/** |
|
98 |
* Add a point to de geometry. |
|
99 |
* |
|
100 |
* @param point |
|
101 |
* Point that is added. |
|
102 |
* |
|
103 |
* @return Number of points that contains the geometry. |
|
104 |
*/ |
|
105 |
public int addPoint(Point2D point) { |
|
106 |
points.add(point); |
|
107 |
|
|
108 |
return points.size(); |
|
109 |
} |
|
110 |
|
|
111 |
/** |
|
112 |
* End the creation of the geometry with the last point added. |
|
113 |
*/ |
|
114 |
public void end() { |
|
115 |
obtainShape((Point2D) points.get(points.size() - 1)); |
|
116 |
} |
|
117 |
|
|
118 |
/** |
|
119 |
* Adds the GeneralPathX with all the points of the geometry. |
|
120 |
* |
|
121 |
* @param gpx |
|
122 |
* GeneralPathX |
|
123 |
*/ |
|
124 |
protected void setGeometry(Geometry geometry) { |
|
125 |
this.geometry = geometry; |
|
126 |
} |
|
127 |
|
|
128 |
/** |
|
129 |
* Obtains the geometry passing him as parameter the last point. |
|
130 |
* |
|
131 |
* @param p |
|
132 |
* Last Point. |
|
133 |
* @throws CreateGeometryException |
|
134 |
*/ |
|
135 |
public abstract void obtainShape(Point2D p); |
|
136 |
|
|
137 |
/** |
|
138 |
* Applies the transformation to all the points of the geometry. |
|
139 |
* |
|
140 |
* @param at |
|
141 |
* AffineTransform |
|
142 |
*/ |
|
143 |
public void applyTransform(AffineTransform at) { |
|
144 |
for (int i = 0; i < points.size(); i++) { |
|
145 |
at.transform((Point2D) points.get(i), (Point2D) points.get(i)); |
|
146 |
} |
|
147 |
|
|
148 |
geometry.transform(at); |
|
149 |
} |
|
150 |
|
|
151 |
/** |
|
152 |
* It draws the geometry on the Graphics that is passed like parameter. |
|
153 |
* |
|
154 |
* @param g |
|
155 |
* Graphics |
|
156 |
* @param at |
|
157 |
* AffineTransform |
|
158 |
* @param symbol |
|
159 |
* FSymbol |
|
160 |
*/ |
|
161 |
public void draw(Graphics2D g, AffineTransform at, ISymbol symbol){ |
|
162 |
symbol.draw(g, at, geometry, null, null); |
|
163 |
} |
|
164 |
|
|
165 |
/** |
|
166 |
* It print the geometry on the Graphics that is passed like parameter. |
|
167 |
* |
|
168 |
* @param g |
|
169 |
* Graphics |
|
170 |
* @param at |
|
171 |
* AffineTransform |
|
172 |
* @param symbol |
|
173 |
* ISymbol |
|
174 |
* @param properties |
|
175 |
*/ |
|
176 |
public void print(Graphics2D g, AffineTransform at, |
|
177 |
ISymbol symbol, PrintAttributes properties){ |
|
178 |
Geometry geom = getGeometry(); |
|
179 |
if (geom instanceof Circle) { |
|
180 |
// circles must be handled differently in order to print really round geometries |
|
181 |
// as the flatness used for screen may not be good for printing |
|
182 |
Circle circle = ((Circle) geom); |
|
183 |
PrintingCircle2D printCircle = new PrintingCircle2D(circle); |
|
184 |
geom = printCircle; |
|
185 |
|
|
186 |
} |
|
187 |
symbol.print(g, at, geom, properties); |
|
188 |
} |
|
189 |
|
|
190 |
/** |
|
191 |
* Paints the geometry on the Graphics adding him the last point if the |
|
192 |
* parameter andLastPoint is true. |
|
193 |
* |
|
194 |
* @param g |
|
195 |
* Graphics |
|
196 |
* @param at |
|
197 |
* AffineTransform |
|
198 |
* @param andLastPoint |
|
199 |
* If true add last point. |
|
200 |
*/ |
|
201 |
public abstract void paint(Graphics2D g, AffineTransform at, |
|
202 |
boolean andLastPoint); |
|
203 |
|
|
204 |
/** |
|
205 |
* Set the point of cursor. |
|
206 |
* |
|
207 |
* @param p |
|
208 |
* Point of cursor. |
|
209 |
*/ |
|
210 |
public abstract void pointPosition(Point2D p); |
|
211 |
|
|
212 |
/** |
|
213 |
* Obtains the shape of the Geometry. |
|
214 |
* |
|
215 |
* @return Geometry. |
|
216 |
* @deprecated |
|
217 |
*/ |
|
218 |
public Geometry getGeometry(AffineTransform at){ |
|
219 |
Geometry clonedGeom = geometry.cloneGeometry(); |
|
220 |
clonedGeom.transform(at); |
|
221 |
return clonedGeom; |
|
222 |
} |
|
223 |
|
|
224 |
/** |
|
225 |
* Returns the geometry to draw |
|
226 |
* @return |
|
227 |
* the geometry |
|
228 |
*/ |
|
229 |
public Geometry getGeometry(){ |
|
230 |
return geometry; |
|
231 |
} |
|
232 |
|
|
233 |
/** |
|
234 |
* Returns all the points of Geometry. |
|
235 |
* |
|
236 |
* @return Array of points. |
|
237 |
*/ |
|
238 |
public Point2D[] getPoints() { |
|
239 |
return (Point2D[]) points.toArray(new Point2D[0]); |
|
240 |
} |
|
241 |
|
|
242 |
/** |
|
243 |
* Draws a handler in each vertex of the Geometry. |
|
244 |
* |
|
245 |
* @param g |
|
246 |
* Graphics |
|
247 |
* @param at |
|
248 |
* AffineTransform. |
|
249 |
*/ |
|
250 |
public void drawVertex(Graphics2D g, AffineTransform at) { |
|
251 |
Point2D[] ps = getPoints(); |
|
252 |
Point2D[] pointRes = new Point2D[ps.length]; |
|
253 |
at.transform(ps, 0, pointRes, 0, ps.length); |
|
254 |
|
|
255 |
int d = 3; |
|
256 |
|
|
257 |
for (int i = 0; i < pointRes.length; i++) { |
|
258 |
g.fillRect((int) pointRes[i].getX() - d, (int) pointRes[i].getY() |
|
259 |
- d, d * 2, d * 2); |
|
260 |
} |
|
261 |
} |
|
262 |
|
|
263 |
/** |
|
264 |
* Modifies a point of the Geometry from an index by the one that is passed |
|
265 |
* like parameter. |
|
266 |
* |
|
267 |
* @param pos |
|
268 |
* Index |
|
269 |
* @param point |
|
270 |
* Point |
|
271 |
*/ |
|
272 |
public void changePoint(int pos, Point2D point) { |
|
273 |
this.points.set(pos, point); |
|
274 |
} |
|
275 |
|
|
276 |
/** |
|
277 |
* Add all the points of Geometry. |
|
278 |
* |
|
279 |
* @param points |
|
280 |
* All points. |
|
281 |
*/ |
|
282 |
public void setPoints(Point2D[] points) { |
|
283 |
this.points.clear(); |
|
284 |
|
|
285 |
for (int i = 0; i < points.length; i++) { |
|
286 |
this.points.add(points[i]); |
|
287 |
} |
|
288 |
} |
|
289 |
|
|
290 |
/** |
|
291 |
* Remove last point of Geometry. |
|
292 |
*/ |
|
293 |
public void delLastPoint() { |
|
294 |
if (points.size() > 0) { |
|
295 |
points.remove(points.size() - 1); |
|
296 |
} |
|
297 |
} |
|
298 |
|
|
299 |
public Object clone() throws CloneNotSupportedException { |
|
300 |
GeometryAdapter cloneAdapter = (GeometryAdapter) super.clone(); |
|
301 |
Collections.copy(cloneAdapter.points, this.points); |
|
302 |
cloneAdapter.geometry = (Geometry) this.geometry.cloneGeometry(); |
|
303 |
return cloneAdapter; |
|
304 |
} |
|
305 |
|
|
306 |
public Rectangle2D getBounds2D() { |
|
307 |
Rectangle2D r = geometry.getBounds2D(); |
|
308 |
double w = r.getWidth(); |
|
309 |
double h = r.getHeight(); |
|
310 |
double x = r.getX(); |
|
311 |
double y = r.getY(); |
|
312 |
boolean modified = false; |
|
313 |
if (r.getWidth() < 0.5) { |
|
314 |
modified = true; |
|
315 |
w = 0.5; |
|
316 |
x = x - 0.25; |
|
317 |
} |
|
318 |
if (r.getHeight() < 0.5) { |
|
319 |
modified = true; |
|
320 |
h = 0.5; |
|
321 |
y = y - 0.25; |
|
322 |
} |
|
323 |
if (modified) { |
|
324 |
return new Rectangle2D.Double(x, y, w, h); |
|
325 |
} |
|
326 |
return r; |
|
327 |
} |
|
328 |
|
|
329 |
public static void registerPersistent() { |
|
330 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
|
331 |
if (manager.getDefinition(PERSISTENCE_DEFINITION_NAME) == null) { |
|
332 |
DynStruct definition = |
|
333 |
manager.addDefinition(GeometryAdapter.class, |
|
334 |
PERSISTENCE_DEFINITION_NAME, |
|
335 |
"GeometryAdapter persistence definition", null, null); |
|
336 |
|
|
337 |
definition.addDynFieldList(POINTS_FIELD) |
|
338 |
.setClassOfItems(Point2D.class).setMandatory(true); |
|
339 |
} |
|
340 |
|
|
341 |
CircleAdapter.registerPersistent(); |
|
342 |
PointAdapter.registerPersistent(); |
|
343 |
PolygonAdapter.registerPersistent(); |
|
344 |
PolyLineAdapter.registerPersistent(); |
|
345 |
RectangleAdapter.registerPersistent(); |
|
346 |
} |
|
347 |
|
|
348 |
public void loadFromState(PersistentState state) |
|
349 |
throws PersistenceException { |
|
350 |
points = state.getList(POINTS_FIELD); |
|
351 |
obtainShape((Point2D) points.get(points.size() - 1)); |
|
352 |
} |
|
353 |
|
|
354 |
public void saveToState(PersistentState state) throws PersistenceException { |
|
355 |
state.set(POINTS_FIELD, points); |
|
356 |
} |
|
357 |
} |
tags/org.gvsig.app.document.layout2.app-2.0.40/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/geometryadapters/PolyLineAdapter.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.app.project.documents.layout.geometryadapters; |
|
23 |
|
|
24 |
import java.awt.Color; |
|
25 |
import java.awt.Graphics2D; |
|
26 |
import java.awt.geom.AffineTransform; |
|
27 |
import java.awt.geom.Point2D; |
|
28 |
|
|
29 |
import org.slf4j.Logger; |
|
30 |
import org.slf4j.LoggerFactory; |
|
31 |
|
|
32 |
import org.gvsig.fmap.geom.Geometry; |
|
33 |
import org.gvsig.fmap.geom.Geometry.SUBTYPES; |
|
34 |
import org.gvsig.fmap.geom.Geometry.TYPES; |
|
35 |
import org.gvsig.fmap.geom.exception.CreateGeometryException; |
|
36 |
import org.gvsig.fmap.geom.primitive.Curve; |
|
37 |
import org.gvsig.fmap.mapcontext.MapContextLocator; |
|
38 |
import org.gvsig.fmap.mapcontext.MapContextManager; |
|
39 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.line.ILineSymbol; |
|
40 |
import org.gvsig.tools.ToolsLocator; |
|
41 |
import org.gvsig.tools.dynobject.DynStruct; |
|
42 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
43 |
|
|
44 |
/** |
|
45 |
* DOCUMENT ME! |
|
46 |
* |
|
47 |
* @author Vicente Caballero Navarro |
|
48 |
*/ |
|
49 |
public class PolyLineAdapter extends GeometryAdapter { |
|
50 |
|
|
51 |
public static final String PERSISTENCE_DEFINITION_NAME = "PolyLineAdapter"; |
|
52 |
private static final Logger logger = LoggerFactory |
|
53 |
.getLogger(PolyLineAdapter.class); |
|
54 |
protected Point2D pointPosition = new Point2D.Double(); |
|
55 |
private AffineTransform identity = new AffineTransform(); |
|
56 |
|
|
57 |
private MapContextManager mapContextManager = MapContextLocator |
|
58 |
.getMapContextManager(); |
|
59 |
|
|
60 |
public PolyLineAdapter() { |
|
61 |
super(); |
|
62 |
} |
|
63 |
|
|
64 |
/** |
|
65 |
* DOCUMENT ME! |
|
66 |
* |
|
67 |
* @param p |
|
68 |
* DOCUMENT ME! |
|
69 |
*/ |
|
70 |
public void obtainShape(Point2D p) { |
|
71 |
Point2D[] points = getPoints(); |
|
72 |
|
|
73 |
try { |
|
74 |
Curve curve = (Curve)geomManager.create(TYPES.CURVE, SUBTYPES.GEOM2D); |
|
75 |
if (points.length > 0) { |
|
76 |
curve.addMoveToVertex(geomManager.createPoint(points[0].getX(), points[0].getY(), SUBTYPES.GEOM2D)); |
|
77 |
} |
|
78 |
for (int i = 1; i < points.length; i++) { |
|
79 |
curve.addVertex(geomManager.createPoint(points[i].getX(), points[i].getY(), SUBTYPES.GEOM2D)); |
|
80 |
} |
|
81 |
if (points.length > 0) { |
|
82 |
curve.addVertex(geomManager.createPoint(p.getX(), p.getY(), SUBTYPES.GEOM2D)); |
|
83 |
} |
|
84 |
|
|
85 |
setGeometry(curve); |
|
86 |
} catch (CreateGeometryException e) { |
|
87 |
logger.error("Error creating the circle", e); |
|
88 |
} |
|
89 |
} |
|
90 |
|
|
91 |
/** |
|
92 |
* DOCUMENT ME! |
|
93 |
* |
|
94 |
* @param g |
|
95 |
* DOCUMENT ME! |
|
96 |
* @param at |
|
97 |
* DOCUMENT ME! |
|
98 |
* @param andLastPoint |
|
99 |
* DOCUMENT ME! |
|
100 |
*/ |
|
101 |
public void paint(Graphics2D g, AffineTransform at, boolean andLastPoint) { |
|
102 |
if (andLastPoint) { |
|
103 |
obtainShape(pointPosition); |
|
104 |
} |
|
105 |
|
|
106 |
Geometry shapeAux = getGeometry(at); |
|
107 |
// ISymbol symbol = new FSymbol(FConstant.SYMBOL_TYPE_LINE, Color.red); |
|
108 |
ILineSymbol symbol = |
|
109 |
(ILineSymbol) mapContextManager.getSymbolManager().createSymbol( |
|
110 |
ILineSymbol.SYMBOL_NAME); |
|
111 |
symbol.setLineColor(Color.RED); |
|
112 |
symbol.draw(g, identity, shapeAux, null, null); |
|
113 |
// FGraphicUtilities.DrawShape(g, identity, shapeAux, |
|
114 |
// new FSymbol(FConstant.SYMBOL_TYPE_LINE, Color.red)); |
|
115 |
} |
|
116 |
|
|
117 |
/** |
|
118 |
* DOCUMENT ME! |
|
119 |
* |
|
120 |
* @param p |
|
121 |
* DOCUMENT ME! |
|
122 |
*/ |
|
123 |
public void pointPosition(Point2D p) { |
|
124 |
pointPosition = p; |
|
125 |
} |
|
126 |
|
|
127 |
public static void registerPersistent() { |
|
128 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
|
129 |
if (manager.getDefinition(PERSISTENCE_DEFINITION_NAME) == null) { |
|
130 |
DynStruct definition = |
|
131 |
manager.addDefinition(PolyLineAdapter.class, |
|
132 |
PERSISTENCE_DEFINITION_NAME, |
|
133 |
"PolyLine Adapter persistence definition", null, null); |
|
134 |
|
|
135 |
definition.extend(manager |
|
136 |
.getDefinition(GeometryAdapter.PERSISTENCE_DEFINITION_NAME)); |
|
137 |
} |
|
138 |
} |
|
139 |
} |
tags/org.gvsig.app.document.layout2.app-2.0.40/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/geometryadapters/CircleAdapter.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.app.project.documents.layout.geometryadapters; |
|
23 |
|
|
24 |
import java.awt.Color; |
|
25 |
import java.awt.Graphics2D; |
|
26 |
import java.awt.geom.AffineTransform; |
|
27 |
import java.awt.geom.Point2D; |
|
28 |
|
|
29 |
import org.slf4j.Logger; |
|
30 |
import org.slf4j.LoggerFactory; |
|
31 |
|
|
32 |
import org.gvsig.fmap.geom.Geometry; |
|
33 |
import org.gvsig.fmap.geom.Geometry.SUBTYPES; |
|
34 |
import org.gvsig.fmap.geom.Geometry.TYPES; |
|
35 |
import org.gvsig.fmap.geom.exception.CreateGeometryException; |
|
36 |
import org.gvsig.fmap.geom.primitive.Circle; |
|
37 |
import org.gvsig.fmap.mapcontext.MapContextLocator; |
|
38 |
import org.gvsig.fmap.mapcontext.MapContextManager; |
|
39 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.line.ILineSymbol; |
|
40 |
import org.gvsig.tools.ToolsLocator; |
|
41 |
import org.gvsig.tools.dynobject.DynStruct; |
|
42 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
43 |
|
|
44 |
/** |
|
45 |
* DOCUMENT ME! |
|
46 |
* |
|
47 |
* @author Vicente Caballero Navarro |
|
48 |
*/ |
|
49 |
public class CircleAdapter extends GeometryAdapter { |
|
50 |
public static final String PERSISTENCE_DEFINITION_NAME = "CircleAdapter"; |
|
51 |
private static final Logger logger = LoggerFactory |
|
52 |
.getLogger(CircleAdapter.class); |
|
53 |
private Point2D pointPosition = new Point2D.Double(); |
|
54 |
private AffineTransform identity = new AffineTransform(); |
|
55 |
|
|
56 |
private MapContextManager mapContextManager = MapContextLocator |
|
57 |
.getMapContextManager(); |
|
58 |
|
|
59 |
public CircleAdapter() { |
|
60 |
super(); |
|
61 |
} |
|
62 |
|
|
63 |
/** |
|
64 |
* DOCUMENT ME! |
|
65 |
* |
|
66 |
* @param g |
|
67 |
* DOCUMENT ME! |
|
68 |
* @param at |
|
69 |
* DOCUMENT ME! |
|
70 |
* @param andLastPoint |
|
71 |
* DOCUMENT ME! |
|
72 |
*/ |
|
73 |
public void paint(Graphics2D g, AffineTransform at, boolean andLastPoint) { |
|
74 |
if (getPoints().length > 0) { |
|
75 |
if (andLastPoint) { |
|
76 |
obtainShape(pointPosition); |
|
77 |
} |
|
78 |
|
|
79 |
Geometry shapeAux = getGeometry(at); |
|
80 |
|
|
81 |
ILineSymbol symbol = |
|
82 |
(ILineSymbol) mapContextManager.getSymbolManager() |
|
83 |
.createSymbol(ILineSymbol.SYMBOL_NAME); |
|
84 |
ILineSymbol redOutline = |
|
85 |
(ILineSymbol) MapContextLocator.getSymbolManager() |
|
86 |
.createSymbol(ILineSymbol.SYMBOL_NAME); |
|
87 |
redOutline.setLineColor(Color.red); |
|
88 |
symbol.draw(g, identity, shapeAux, null, null); |
|
89 |
} |
|
90 |
} |
|
91 |
|
|
92 |
/** |
|
93 |
* DOCUMENT ME! |
|
94 |
* |
|
95 |
* @param p |
|
96 |
* DOCUMENT ME! |
|
97 |
*/ |
|
98 |
public void pointPosition(Point2D p) { |
|
99 |
pointPosition = p; |
|
100 |
} |
|
101 |
|
|
102 |
/** |
|
103 |
* DOCUMENT ME! |
|
104 |
* |
|
105 |
* @param p |
|
106 |
* DOCUMENT ME! |
|
107 |
* @throws CreateGeometryException |
|
108 |
*/ |
|
109 |
public void obtainShape(Point2D p) { |
|
110 |
Point2D[] points = getPoints(); |
|
111 |
|
|
112 |
double x = (points[0]).getX(); |
|
113 |
double y = (points[0]).getY(); |
|
114 |
double r = p.distance(points[0]); |
|
115 |
|
|
116 |
try { |
|
117 |
Circle circle = (Circle)geomManager.create(TYPES.CIRCLE, SUBTYPES.GEOM2D); |
|
118 |
|
|
119 |
double flatness = geomManager.getFlatness(); |
|
120 |
|
|
121 |
geomManager.setFlatness(0.01); |
|
122 |
circle.setPoints(geomManager.createPoint(x, y, SUBTYPES.GEOM2D), r) ; |
|
123 |
geomManager.setFlatness(flatness); |
|
124 |
|
|
125 |
setGeometry(circle); |
|
126 |
} catch (CreateGeometryException e) { |
|
127 |
logger.error("Error creating the circle", e); |
|
128 |
} |
|
129 |
} |
|
130 |
|
|
131 |
public static void registerPersistent() { |
|
132 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
|
133 |
if (manager.getDefinition(PERSISTENCE_DEFINITION_NAME) == null) { |
|
134 |
DynStruct definition = |
|
135 |
manager.addDefinition(CircleAdapter.class, |
|
136 |
PERSISTENCE_DEFINITION_NAME, |
|
137 |
"Circle Adapter persistence definition", null, null); |
|
138 |
|
|
139 |
definition.extend(manager |
|
140 |
.getDefinition(GeometryAdapter.PERSISTENCE_DEFINITION_NAME)); |
|
141 |
} |
|
142 |
} |
|
143 |
} |
tags/org.gvsig.app.document.layout2.app-2.0.40/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/geometryadapters/PrintingCircle2D.java | ||
---|---|---|
1 |
package org.gvsig.app.project.documents.layout.geometryadapters; |
|
2 |
|
|
3 |
//public class PrintingCircle2D {} |
|
4 |
|
|
5 |
|
|
6 |
import java.awt.Rectangle; |
|
7 |
import java.awt.Shape; |
|
8 |
import java.awt.geom.AffineTransform; |
|
9 |
import java.awt.geom.PathIterator; |
|
10 |
import java.awt.geom.Point2D; |
|
11 |
import java.awt.geom.Rectangle2D; |
|
12 |
|
|
13 |
import org.cresques.cts.ICoordTrans; |
|
14 |
import org.gvsig.fmap.geom.Geometry; |
|
15 |
import org.gvsig.fmap.geom.handler.Handler; |
|
16 |
import org.gvsig.fmap.geom.operation.GeometryOperationContext; |
|
17 |
import org.gvsig.fmap.geom.operation.GeometryOperationException; |
|
18 |
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException; |
|
19 |
import org.gvsig.fmap.geom.primitive.Circle; |
|
20 |
import org.gvsig.fmap.geom.primitive.Envelope; |
|
21 |
import org.gvsig.fmap.geom.primitive.GeneralPathX; |
|
22 |
import org.gvsig.fmap.geom.primitive.Point; |
|
23 |
import org.gvsig.fmap.geom.primitive.Ring; |
|
24 |
import org.gvsig.fmap.geom.primitive.SurfaceAppearance; |
|
25 |
import org.gvsig.fmap.geom.type.GeometryType; |
|
26 |
|
|
27 |
public class PrintingCircle2D implements Circle { |
|
28 |
Circle delegate; |
|
29 |
|
|
30 |
public PrintingCircle2D(Circle delegate) { |
|
31 |
this.delegate = delegate; |
|
32 |
} |
|
33 |
|
|
34 |
public Shape getInternalShape() { |
|
35 |
return delegate.getInternalShape(); |
|
36 |
} |
|
37 |
|
|
38 |
public Shape getShape() { |
|
39 |
return delegate.getShape(); |
|
40 |
} |
|
41 |
|
|
42 |
public Shape getShape(AffineTransform affineTransform) { |
|
43 |
double radious = getRadious(); |
|
44 |
Point2D origin = new Point2D.Double(getCenter().getCoordinateAt(0)-radious, getCenter().getCoordinateAt(1)-radious); |
|
45 |
Point2D radiusTrans = new Point2D.Double(radious, radious); |
|
46 |
affineTransform.transform(origin, origin); |
|
47 |
affineTransform.transform(radiusTrans, radiusTrans); |
|
48 |
java.awt.geom.Ellipse2D.Double ellipse = |
|
49 |
new java.awt.geom.Ellipse2D.Double(origin.getX(), |
|
50 |
origin.getY(), radiusTrans.getX(), radiusTrans.getY()); |
|
51 |
return ellipse; |
|
52 |
} |
|
53 |
|
|
54 |
public void setPoints(Point center, Point radious) { |
|
55 |
delegate.setPoints(center, radious); |
|
56 |
} |
|
57 |
|
|
58 |
public void setPoints(Point center, double radious) { |
|
59 |
delegate.setPoints(center, radious); |
|
60 |
} |
|
61 |
|
|
62 |
public void setPoints(Point p1, Point p2, Point p3) { |
|
63 |
delegate.setPoints(p1, p2, p3); |
|
64 |
} |
|
65 |
|
|
66 |
public Point getCenter() { |
|
67 |
return delegate.getCenter(); |
|
68 |
} |
|
69 |
|
|
70 |
public Rectangle getBounds() { |
|
71 |
return delegate.getBounds(); |
|
72 |
} |
|
73 |
|
|
74 |
public double getRadious() { |
|
75 |
return delegate.getRadious(); |
|
76 |
} |
|
77 |
|
|
78 |
public void setSurfaceAppearance(SurfaceAppearance app) { |
|
79 |
delegate.setSurfaceAppearance(app); |
|
80 |
} |
|
81 |
|
|
82 |
public SurfaceAppearance getSurfaceAppearance() { |
|
83 |
return delegate.getSurfaceAppearance(); |
|
84 |
} |
|
85 |
|
|
86 |
public double getCoordinateAt(int index, int dimension) { |
|
87 |
return delegate.getCoordinateAt(index, dimension); |
|
88 |
} |
|
89 |
|
|
90 |
public int getNumInteriorRings() { |
|
91 |
return delegate.getNumInteriorRings(); |
|
92 |
} |
|
93 |
|
|
94 |
public Ring getInteriorRing(int index) { |
|
95 |
return delegate.getInteriorRing(index); |
|
96 |
} |
|
97 |
|
|
98 |
public void addInteriorRing(Ring ring) { |
|
99 |
delegate.addInteriorRing(ring); |
|
100 |
} |
|
101 |
|
|
102 |
public void removeInteriorRing(int index) { |
|
103 |
delegate.removeInteriorRing(index); |
|
104 |
} |
|
105 |
|
|
106 |
public void setCoordinateAt(int index, int dimension, double value) { |
|
107 |
delegate.setCoordinateAt(index, dimension, value); |
|
108 |
} |
|
109 |
|
|
110 |
public void addVertex(Point point) { |
|
111 |
delegate.addVertex(point); |
|
112 |
} |
|
113 |
|
|
114 |
public void addVertex(double x, double y) { |
|
115 |
delegate.addVertex(x, y); |
|
116 |
} |
|
117 |
|
|
118 |
public int compareTo(Object o) { |
|
119 |
return delegate.compareTo(o); |
|
120 |
} |
|
121 |
|
|
122 |
public void addVertex(double x, double y, double z) { |
|
123 |
delegate.addVertex(x, y, z); |
|
124 |
} |
|
125 |
|
|
126 |
public void removeVertex(int index) { |
|
127 |
delegate.removeVertex(index); |
|
128 |
} |
|
129 |
|
|
130 |
public Point getVertex(int index) { |
|
131 |
return delegate.getVertex(index); |
|
132 |
} |
|
133 |
|
|
134 |
public boolean contains(double x, double y) { |
|
135 |
return delegate.contains(x, y); |
|
136 |
} |
|
137 |
|
|
138 |
public int getNumVertices() { |
|
139 |
return delegate.getNumVertices(); |
|
140 |
} |
|
141 |
|
|
142 |
public void insertVertex(int index, Point p) { |
|
143 |
delegate.insertVertex(index, p); |
|
144 |
} |
|
145 |
|
|
146 |
public boolean contains(Point2D p) { |
|
147 |
return delegate.contains(p); |
|
148 |
} |
|
149 |
|
|
150 |
public void setVertex(int index, Point p) { |
|
151 |
delegate.setVertex(index, p); |
|
152 |
} |
|
153 |
|
|
154 |
public void setGeneralPath(GeneralPathX generalPathX) { |
|
155 |
delegate.setGeneralPath(generalPathX); |
|
156 |
} |
|
157 |
|
|
158 |
public boolean intersects(double x, double y, double w, double h) { |
|
159 |
return delegate.intersects(x, y, w, h); |
|
160 |
} |
|
161 |
|
|
162 |
public void addMoveToVertex(Point point) { |
|
163 |
delegate.addMoveToVertex(point); |
|
164 |
} |
|
165 |
|
|
166 |
public void closePrimitive() { |
|
167 |
delegate.closePrimitive(); |
|
168 |
} |
|
169 |
|
|
170 |
public void ensureCapacity(int capacity) { |
|
171 |
delegate.ensureCapacity(capacity); |
|
172 |
} |
|
173 |
|
|
174 |
public boolean contains(double x, double y, double w, double h) { |
|
175 |
return delegate.contains(x, y, w, h); |
|
176 |
} |
|
177 |
|
|
178 |
public int getType() { |
|
179 |
return delegate.getType(); |
|
180 |
} |
|
181 |
|
|
182 |
public Geometry cloneGeometry() { |
|
183 |
return delegate.cloneGeometry(); |
|
184 |
} |
|
185 |
|
|
186 |
public boolean intersects(Rectangle2D r) { |
|
187 |
return delegate.intersects(r); |
|
188 |
} |
|
189 |
|
|
190 |
public boolean contains(Rectangle2D r) { |
|
191 |
return delegate.contains(r); |
|
192 |
} |
|
193 |
|
|
194 |
public boolean fastIntersects(double x, double y, double w, double h) { |
|
195 |
return delegate.fastIntersects(x, y, w, h); |
|
196 |
} |
|
197 |
|
|
198 |
public Envelope getEnvelope() { |
|
199 |
return delegate.getEnvelope(); |
|
200 |
} |
|
201 |
|
|
202 |
public void reProject(ICoordTrans ct) { |
|
203 |
delegate.reProject(ct); |
|
204 |
} |
|
205 |
|
|
206 |
public void transform(AffineTransform at) { |
|
207 |
delegate.transform(at); |
|
208 |
} |
|
209 |
|
|
210 |
public int getDimension() { |
|
211 |
return delegate.getDimension(); |
|
212 |
} |
|
213 |
|
|
214 |
public boolean isSimple() { |
|
215 |
return delegate.isSimple(); |
Also available in: Unified diff