Revision 128
tags/org.gvsig.app.document.layout.app-2.0.21/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.layout.app</artifactId> |
|
5 |
<packaging>pom</packaging> |
|
6 |
<version>2.0.21</version> |
|
7 |
|
|
8 |
<name>Document: Layout document support</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.plugin</artifactId> |
|
14 |
<version>2.0.24</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.layout.app-2.0.21</connection> |
|
21 |
<developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-app-document-layout/tags/org.gvsig.app.document.layout.app-2.0.21</developerConnection> |
|
22 |
<url>https://devel.gvsig.org/redmine/projects/gvsig-app-document-layout/repository/show/tags/org.gvsig.app.document.layout.app-2.0.21</url> |
|
23 |
</scm> |
|
24 |
|
|
25 |
<build> |
|
26 |
<plugins> |
|
27 |
<plugin> |
|
28 |
<groupId>org.apache.maven.plugins</groupId> |
|
29 |
<artifactId>maven-release-plugin</artifactId> |
|
30 |
<configuration> |
|
31 |
<tagBase>https://devel.gvsig.org/svn/gvsig-app-document-layout/tags</tagBase> |
|
32 |
</configuration> |
|
33 |
</plugin> |
|
34 |
</plugins> |
|
35 |
</build> |
|
36 |
|
|
37 |
<modules> |
|
38 |
<module>org.gvsig.app.document.layout.app.mainplugin</module> |
|
39 |
</modules> |
|
40 |
<properties> |
|
41 |
<gvsig.package.info.state>testing</gvsig.package.info.state> |
|
42 |
<!-- alpha-devel --> |
|
43 |
<gvsig.package.info.official>true</gvsig.package.info.official> |
|
44 |
|
|
45 |
</properties> |
|
46 |
|
|
47 |
</project> |
tags/org.gvsig.app.document.layout.app-2.0.21/org.gvsig.app.document.layout.app.mainplugin/pom.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
|
|
3 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|
4 |
|
|
5 |
<modelVersion>4.0.0</modelVersion> |
|
6 |
<packaging>jar</packaging> |
|
7 |
<artifactId>org.gvsig.app.document.layout.app.mainplugin</artifactId> |
|
8 |
<name>Document: Layout document support</name> |
|
9 |
|
|
10 |
|
|
11 |
<parent> |
|
12 |
<groupId>org.gvsig</groupId> |
|
13 |
<artifactId>org.gvsig.app.document.layout.app</artifactId> |
|
14 |
<version>2.0.21</version> |
|
15 |
</parent> |
|
16 |
|
|
17 |
<dependencies> |
|
18 |
|
|
19 |
<dependency> |
|
20 |
<groupId>org.gvsig</groupId> |
|
21 |
<artifactId>org.gvsig.app.mainplugin</artifactId> |
|
22 |
<scope>compile</scope> |
|
23 |
</dependency> |
|
24 |
<dependency> |
|
25 |
<groupId>org.gvsig</groupId> |
|
26 |
<artifactId>org.gvsig.andami</artifactId> |
|
27 |
<scope>compile</scope> |
|
28 |
</dependency> |
|
29 |
<dependency> |
|
30 |
<groupId>org.gvsig</groupId> |
|
31 |
<artifactId>org.gvsig.fmap.control</artifactId> |
|
32 |
<scope>compile</scope> |
|
33 |
</dependency> |
|
34 |
<dependency> |
|
35 |
<groupId>org.gvsig</groupId> |
|
36 |
<artifactId>org.gvsig.tools.lib</artifactId> |
|
37 |
<scope>compile</scope> |
|
38 |
</dependency> |
|
39 |
<dependency> |
|
40 |
<groupId>org.gvsig</groupId> |
|
41 |
<artifactId>org.gvsig.tools.swing.api</artifactId> |
|
42 |
<scope>compile</scope> |
|
43 |
</dependency> |
|
44 |
<dependency> |
|
45 |
<groupId>org.gvsig</groupId> |
|
46 |
<artifactId>org.gvsig.fmap.mapcontext.api</artifactId> |
|
47 |
<scope>compile</scope> |
|
48 |
</dependency> |
|
49 |
<dependency> |
|
50 |
<groupId>org.gvsig</groupId> |
|
51 |
<artifactId>org.gvsig.fmap.mapcontext.operation</artifactId> |
|
52 |
<scope>compile</scope> |
|
53 |
</dependency> |
|
54 |
<dependency> |
|
55 |
<groupId>org.gvsig</groupId> |
|
56 |
<artifactId>org.gvsig.fmap.geometry.api</artifactId> |
|
57 |
<scope>compile</scope> |
|
58 |
</dependency> |
|
59 |
<dependency> |
|
60 |
<groupId>org.gvsig</groupId> |
|
61 |
<artifactId>org.gvsig.utils</artifactId> |
|
62 |
<scope>compile</scope> |
|
63 |
</dependency> |
|
64 |
<dependency> |
|
65 |
<groupId>org.gvsig</groupId> |
|
66 |
<artifactId>org.gvsig.ui</artifactId> |
|
67 |
<scope>compile</scope> |
|
68 |
</dependency> |
|
69 |
<dependency> |
|
70 |
<groupId>org.gvsig</groupId> |
|
71 |
<artifactId>org.gvsig.fmap.dal.api</artifactId> |
|
72 |
<scope>compile</scope> |
|
73 |
</dependency> |
|
74 |
<dependency> |
|
75 |
<groupId>org.gvsig</groupId> |
|
76 |
<artifactId>org.gvsig.compat.api</artifactId> |
|
77 |
<scope>compile</scope> |
|
78 |
</dependency> |
|
79 |
<dependency> |
|
80 |
<groupId>org.gvsig</groupId> |
|
81 |
<artifactId>org.gvsig.projection.api</artifactId> |
|
82 |
<scope>compile</scope> |
|
83 |
</dependency> |
|
84 |
<dependency> |
|
85 |
<groupId>org.gvsig</groupId> |
|
86 |
<artifactId>org.gvsig.symbology.lib.api</artifactId> |
|
87 |
<scope>compile</scope> |
|
88 |
</dependency> |
|
89 |
<dependency> |
|
90 |
<groupId>org.gvsig</groupId> |
|
91 |
<artifactId>org.gvsig.symbology.swing.api</artifactId> |
|
92 |
<scope>compile</scope> |
|
93 |
</dependency> |
|
94 |
<dependency> |
|
95 |
<groupId>org.gvsig</groupId> |
|
96 |
<artifactId>org.gvsig.metadata.lib.basic.api</artifactId> |
|
97 |
<scope>compile</scope> |
|
98 |
</dependency> |
|
99 |
<dependency> |
|
100 |
<groupId>com.lowagie</groupId> |
|
101 |
<artifactId>itext</artifactId> |
|
102 |
<scope>compile</scope> |
|
103 |
</dependency> |
|
104 |
<dependency> |
|
105 |
<groupId>org.apache.xmlgraphics</groupId> |
|
106 |
<artifactId>batik-gvt</artifactId> |
|
107 |
<scope>compile</scope> |
|
108 |
</dependency> |
|
109 |
<dependency> |
|
110 |
<groupId>org.apache.xmlgraphics</groupId> |
|
111 |
<artifactId>batik-script</artifactId> |
|
112 |
<scope>compile</scope> |
|
113 |
</dependency> |
|
114 |
|
|
115 |
<!-- |
|
116 |
<dependency> |
|
117 |
<groupId>org.gvsig</groupId> |
|
118 |
<artifactId>batik-ext-gvsig-custom</artifactId> |
|
119 |
</dependency> |
|
120 |
--> |
|
121 |
|
|
122 |
<dependency> |
|
123 |
<groupId>com.sun</groupId> |
|
124 |
<artifactId>jimi</artifactId> |
|
125 |
<scope>compile</scope> |
|
126 |
</dependency> |
|
127 |
<dependency> |
|
128 |
<groupId>org.gvsig</groupId> |
|
129 |
<artifactId>org.gvsig.i18n</artifactId> |
|
130 |
<scope>compile</scope> |
|
131 |
</dependency> |
|
132 |
|
|
133 |
</dependencies> |
|
134 |
|
|
135 |
<properties> |
|
136 |
<gvsig.package.info.dependencies>required: org.gvsig.app.mainplugin -ge 2.0.22</gvsig.package.info.dependencies> |
|
137 |
<gvsig.package.info.categories>Layout</gvsig.package.info.categories> |
|
138 |
<gvsig.package.info.poolURL>http://devel.gvsig.org/download/projects/gvsig-app-document-layout/pool</gvsig.package.info.poolURL> |
|
139 |
<gvsig.package.info.sourcesURL>https://devel.gvsig.org/svn/gvsig-app-document-layout</gvsig.package.info.sourcesURL> |
|
140 |
</properties> |
|
141 |
|
|
142 |
</project> |
|
143 |
|
tags/org.gvsig.app.document.layout.app-2.0.21/org.gvsig.app.document.layout.app.mainplugin/buildNumber.properties | ||
---|---|---|
1 |
#maven.buildNumber.plugin properties file |
|
2 |
#Mon Jul 08 09:50:23 CEST 2013 |
|
3 |
buildNumber=35 |
tags/org.gvsig.app.document.layout.app-2.0.21/org.gvsig.app.document.layout.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> |
tags/org.gvsig.app.document.layout.app-2.0.21/org.gvsig.app.document.layout.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.layout.app-2.0.21/org.gvsig.app.document.layout.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/LayoutContext.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; |
|
23 |
|
|
24 |
import java.awt.geom.AffineTransform; |
|
25 |
|
|
26 |
import org.gvsig.app.project.documents.layout.commands.FrameCommandsRecord; |
|
27 |
import org.gvsig.app.project.documents.layout.fframes.IFFrame; |
|
28 |
import org.gvsig.tools.observer.Observable; |
|
29 |
import org.gvsig.tools.persistence.Persistent; |
|
30 |
|
|
31 |
/** |
|
32 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodrá</a> |
|
33 |
*/ |
|
34 |
public interface LayoutContext extends Persistent, Observable { |
|
35 |
|
|
36 |
/** |
|
37 |
* Returns the AffineTransform that is applying in the Layout. |
|
38 |
* |
|
39 |
* @return AffineTransform |
|
40 |
*/ |
|
41 |
public AffineTransform getAT(); |
|
42 |
|
|
43 |
/** |
|
44 |
* Call all LayoutDrawListeners. |
|
45 |
* |
|
46 |
*/ |
|
47 |
public void notifAllObservers(); |
|
48 |
|
|
49 |
/** |
|
50 |
* It returns the print attributes of the Layout. |
|
51 |
* |
|
52 |
* @return Attributes. |
|
53 |
*/ |
|
54 |
public Attributes getAttributes(); |
|
55 |
|
|
56 |
/** |
|
57 |
* Inserts the print attributes of Layout. |
|
58 |
* |
|
59 |
* @param attributes |
|
60 |
* Attributes. |
|
61 |
*/ |
|
62 |
public void setAtributes(Attributes attributes); |
|
63 |
|
|
64 |
/** |
|
65 |
* It obtains the Array with all the FFrames that have been added al Layout. |
|
66 |
* |
|
67 |
* @return Array with all the FFrames that have been added al Layout. |
|
68 |
*/ |
|
69 |
public IFFrame[] getFFrames(); |
|
70 |
|
|
71 |
/** |
|
72 |
* It obtains the FFrame from an index. |
|
73 |
**/ |
|
74 |
public IFFrame getFFrame(int i); |
|
75 |
|
|
76 |
/** |
|
77 |
* It orders the FFrames depending on its position specified by level. |
|
78 |
* |
|
79 |
*/ |
|
80 |
public void updateFFrames(); |
|
81 |
|
|
82 |
/** |
|
83 |
* Remove the fframes selected. |
|
84 |
* |
|
85 |
*/ |
|
86 |
public void delFFrameSelected(); |
|
87 |
|
|
88 |
/** |
|
89 |
* Clear the selection of FFrames. |
|
90 |
* |
|
91 |
*/ |
|
92 |
public void clearSelection(); |
|
93 |
|
|
94 |
/** |
|
95 |
* Remove the fframe of index. |
|
96 |
* |
|
97 |
*/ |
|
98 |
public void delFFrame(int index); |
|
99 |
|
|
100 |
/** |
|
101 |
* Remove the fframe of parameter. |
|
102 |
* |
|
103 |
* @param frame |
|
104 |
* FFrame to remove. |
|
105 |
*/ |
|
106 |
public void delFFrame(IFFrame frame); |
|
107 |
|
|
108 |
/** |
|
109 |
* Returns the EditableFeatureSource, is the control of all change in the |
|
110 |
* FFrames of Layout. |
|
111 |
* |
|
112 |
* @return EditableFatureSource. |
|
113 |
*/ |
|
114 |
public FrameCommandsRecord getFrameCommandsRecord(); |
|
115 |
|
|
116 |
/** |
|
117 |
* It adds a fframe to Arraylist of FFrames . |
|
118 |
* |
|
119 |
* @param frame |
|
120 |
* fframe to add. |
|
121 |
* @param clearSelection |
|
122 |
* True |
|
123 |
* True if clean the selection of the fframes already added and |
|
124 |
* false if intends to maintain the same selection. |
|
125 |
* @param select |
|
126 |
* Boolean that indicates if has to remain selected the FFrame |
|
127 |
* that is added or not. |
|
128 |
*/ |
|
129 |
public void addFFrame(IFFrame frame, boolean clearSelection, boolean select); |
|
130 |
|
|
131 |
/** |
|
132 |
* It adds a fframe to Arraylist of FFrames with the same properties. |
|
133 |
* |
|
134 |
* @param frame |
|
135 |
* fframe to add. |
|
136 |
*/ |
|
137 |
public void addFFrameSameProperties(IFFrame frame); |
|
138 |
|
|
139 |
/** |
|
140 |
* Returns other number behind the current fframes. |
|
141 |
* |
|
142 |
* @return new Position behind. |
|
143 |
*/ |
|
144 |
public int getNumBehind(); |
|
145 |
|
|
146 |
/** |
|
147 |
* Returns other number before the current fframes. |
|
148 |
* |
|
149 |
* @return new Position before. |
|
150 |
*/ |
|
151 |
public int getNumBefore(); |
|
152 |
|
|
153 |
/** |
|
154 |
* It returns all the fframes included them erased and modified in all |
|
155 |
* its previous forms. |
|
156 |
* |
|
157 |
* @return IFFrame[] Array of FFrames. |
|
158 |
*/ |
|
159 |
public IFFrame[] getAllFFrames(); |
|
160 |
|
|
161 |
/** |
|
162 |
* It returns an array with the FFrames selected. |
|
163 |
* |
|
164 |
* @return Array with the FFrames selected. |
|
165 |
*/ |
|
166 |
public IFFrame[] getFFrameSelected(); |
|
167 |
|
|
168 |
/** |
|
169 |
* It returns if the Layout is in edition. |
|
170 |
* |
|
171 |
* @return True if Layout is in edition. |
|
172 |
*/ |
|
173 |
public boolean isEditable(); |
|
174 |
|
|
175 |
/** |
|
176 |
* It inserts if the Layout is in edition. |
|
177 |
* |
|
178 |
* @param b |
|
179 |
* True if Layout is in edition. |
|
180 |
*/ |
|
181 |
public void setEditable(boolean b); |
|
182 |
|
|
183 |
/** |
|
184 |
* It returns if has been applying in the fframes that are added to Layout |
|
185 |
* the grid, or not. |
|
186 |
* |
|
187 |
* @return true if has been applying the grid. |
|
188 |
*/ |
|
189 |
public boolean isAdjustingToGrid(); |
|
190 |
|
|
191 |
/** |
|
192 |
* It inserts if has been applying in the fframes that are added to Layout |
|
193 |
* the grid, or not. |
|
194 |
* |
|
195 |
* @param b |
|
196 |
* true if has been applying the grid. |
|
197 |
*/ |
|
198 |
public void setAdjustToGrid(boolean b); |
|
199 |
|
|
200 |
/** |
|
201 |
* It inserts if is shown or not the rule of the Layout. |
|
202 |
* |
|
203 |
* @param b |
|
204 |
* True if is shown or not the rule of the Layout. |
|
205 |
*/ |
|
206 |
public void setRuler(boolean b); |
|
207 |
|
|
208 |
/** |
|
209 |
* Returns if is shown or not the rule of the Layout. |
|
210 |
* |
|
211 |
* @return True si se muestra la regla. |
|
212 |
*/ |
|
213 |
public boolean getRuler(); |
|
214 |
|
|
215 |
/** |
|
216 |
* It returns if has been showing the grid of Layout, or not. |
|
217 |
* |
|
218 |
* @return true if has been showing the grid of Layout. |
|
219 |
*/ |
|
220 |
public boolean isGridVisible(); |
|
221 |
|
|
222 |
/** |
|
223 |
* It inserts if draws the Grid in the Layout or not. |
|
224 |
* |
|
225 |
* @param b |
|
226 |
* True if draws the Grid in the Layout. |
|
227 |
*/ |
|
228 |
public void setGridVisible(boolean b); |
|
229 |
|
|
230 |
/** |
|
231 |
* Refresh all FFrames of Layout. |
|
232 |
*/ |
|
233 |
public void fullRefresh(); |
|
234 |
|
|
235 |
public void setNumBehind(int numBehind); |
|
236 |
|
|
237 |
public void setNumBefore(int numBefore); |
|
238 |
|
|
239 |
} |
tags/org.gvsig.app.document.layout.app-2.0.21/org.gvsig.app.document.layout.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/DefaultLayoutControl.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; |
|
23 |
|
|
24 |
import java.awt.Color; |
|
25 |
import java.awt.Cursor; |
|
26 |
import java.awt.Graphics; |
|
27 |
import java.awt.Graphics2D; |
|
28 |
import java.awt.Image; |
|
29 |
import java.awt.Point; |
|
30 |
import java.awt.Rectangle; |
|
31 |
import java.awt.Toolkit; |
|
32 |
import java.awt.geom.AffineTransform; |
|
33 |
import java.awt.geom.Rectangle2D; |
|
34 |
import java.awt.image.BufferedImage; |
|
35 |
import java.awt.image.MemoryImageSource; |
|
36 |
import java.util.HashMap; |
|
37 |
|
|
38 |
import javax.swing.JComponent; |
|
39 |
|
|
40 |
import org.gvsig.app.project.documents.layout.fframes.IFFrame; |
|
41 |
import org.gvsig.app.project.documents.layout.fframes.IFFrameEditableVertex; |
|
42 |
import org.gvsig.app.project.documents.layout.fframes.IFFrameUseFMap; |
|
43 |
import org.gvsig.app.project.documents.layout.geometryadapters.GeometryAdapter; |
|
44 |
import org.gvsig.app.project.documents.layout.geometryadapters.PolyLineAdapter; |
|
45 |
import org.gvsig.app.project.documents.layout.gui.LayoutPanel; |
|
46 |
import org.gvsig.app.project.documents.layout.tools.LayoutAddBoxListenerImpl; |
|
47 |
import org.gvsig.app.project.documents.layout.tools.LayoutAddCircleListenerImpl; |
|
48 |
import org.gvsig.app.project.documents.layout.tools.LayoutAddLegendListenerImpl; |
|
49 |
import org.gvsig.app.project.documents.layout.tools.LayoutAddLineListenerImpl; |
|
50 |
import org.gvsig.app.project.documents.layout.tools.LayoutAddNorthListenerImpl; |
|
51 |
import org.gvsig.app.project.documents.layout.tools.LayoutAddOverViewListenerImpl; |
|
52 |
import org.gvsig.app.project.documents.layout.tools.LayoutAddPictureListenerImpl; |
|
53 |
import org.gvsig.app.project.documents.layout.tools.LayoutAddPointListenerImpl; |
|
54 |
import org.gvsig.app.project.documents.layout.tools.LayoutAddPolygonListenerImpl; |
|
55 |
import org.gvsig.app.project.documents.layout.tools.LayoutAddPolylineListenerImpl; |
|
56 |
import org.gvsig.app.project.documents.layout.tools.LayoutAddRectangleListenerImpl; |
|
57 |
import org.gvsig.app.project.documents.layout.tools.LayoutAddScaleListenerImpl; |
|
58 |
import org.gvsig.app.project.documents.layout.tools.LayoutAddTextListenerImpl; |
|
59 |
import org.gvsig.app.project.documents.layout.tools.LayoutAddViewListenerImpl; |
|
60 |
import org.gvsig.app.project.documents.layout.tools.LayoutEditGraphicsListenerImpl; |
|
61 |
import org.gvsig.app.project.documents.layout.tools.LayoutPanListenerImpl; |
|
62 |
import org.gvsig.app.project.documents.layout.tools.LayoutSelectListenerImpl; |
|
63 |
import org.gvsig.app.project.documents.layout.tools.LayoutViewPanListenerImpl; |
|
64 |
import org.gvsig.app.project.documents.layout.tools.LayoutViewZoomInListenerImpl; |
|
65 |
import org.gvsig.app.project.documents.layout.tools.LayoutViewZoomOutListenerImpl; |
|
66 |
import org.gvsig.app.project.documents.layout.tools.LayoutZoomInListenerImpl; |
|
67 |
import org.gvsig.app.project.documents.layout.tools.LayoutZoomOutListenerImpl; |
|
68 |
import org.gvsig.app.project.documents.layout.tools.behavior.LayoutBehavior; |
|
69 |
import org.gvsig.app.project.documents.layout.tools.behavior.LayoutEditBehavior; |
|
70 |
import org.gvsig.app.project.documents.layout.tools.behavior.LayoutMoveBehavior; |
|
71 |
import org.gvsig.app.project.documents.layout.tools.behavior.LayoutPointBehavior; |
|
72 |
import org.gvsig.app.project.documents.layout.tools.behavior.LayoutRectangleBehavior; |
|
73 |
import org.gvsig.app.project.documents.layout.tools.behavior.LayoutSelectBehavior; |
|
74 |
import org.gvsig.app.project.documents.layout.tools.behavior.LayoutViewMoveBehavior; |
|
75 |
import org.gvsig.app.project.documents.layout.tools.behavior.LayoutViewZoomBehavior; |
|
76 |
import org.gvsig.app.project.documents.layout.tools.behavior.LayoutZoomBehavior; |
|
77 |
import org.gvsig.app.project.documents.layout.tools.listener.ILayoutGraphicListener; |
|
78 |
import org.gvsig.fmap.dal.exception.ReadException; |
|
79 |
import org.gvsig.tools.observer.Observable; |
|
80 |
|
|
81 |
/** |
|
82 |
* Control of Layout. |
|
83 |
* |
|
84 |
* @author Vicente Caballero Navarro |
|
85 |
*/ |
|
86 |
public class DefaultLayoutControl extends JComponent implements LayoutControl { |
|
87 |
private static final int DESACTUALIZADO = 4; |
|
88 |
private static final int ACTUALIZADO = 5; |
|
89 |
|
|
90 |
private static final long serialVersionUID = -8290006366669291510L; |
|
91 |
|
|
92 |
public static final String PERSISTENCE_DEFINITION_NAME = "LayoutControl"; |
|
93 |
|
|
94 |
private int status = DESACTUALIZADO; |
|
95 |
private Rectangle2D rectVisible; |
|
96 |
private BufferedImage img = null; |
|
97 |
private BufferedImage imgRuler = null; |
|
98 |
private boolean initial = true; |
|
99 |
private LayoutContext layoutContext; |
|
100 |
private Point origin = new Point(50, 50); |
|
101 |
private Point rectOrigin = new Point(origin); |
|
102 |
private Rectangle2D.Double rect = new Rectangle2D.Double(rectOrigin.x, |
|
103 |
rectOrigin.y, 400, 300); |
|
104 |
private FLayoutDraw layoutDraw = null; |
|
105 |
private FLayoutFunctions layoutFunctions = null; |
|
106 |
private LayoutBehavior currentLayoutTool = null; |
|
107 |
private Image imageCursor = null; |
|
108 |
private HashMap namesLayoutTools = new HashMap(); |
|
109 |
private Point m_FirstPoint = new Point(0, 0); |
|
110 |
private Point m_PointAnt = new Point(0, 0); |
|
111 |
private Point m_LastPoint = new Point(0, 0); |
|
112 |
private LayoutEvents layoutEvents; |
|
113 |
private Point position; |
|
114 |
private GeometryAdapter geometryAdapter = new PolyLineAdapter(); |
|
115 |
|
|
116 |
// private String prevTool; |
|
117 |
private String currentTool; |
|
118 |
private boolean m_bCancelDrawing = false; |
|
119 |
private Rectangle reSel = null; |
|
120 |
private boolean isReSel = true; |
|
121 |
private FLayoutZooms layoutZooms; |
|
122 |
|
|
123 |
private static Cursor transparentCursor = Toolkit.getDefaultToolkit() |
|
124 |
.createCustomCursor( |
|
125 |
Toolkit.getDefaultToolkit().createImage( |
|
126 |
new MemoryImageSource(16, 16, new int[16 * 16], 0, 16)), |
|
127 |
new Point(0, 0), "invisiblecursor"); |
|
128 |
|
|
129 |
/** |
|
130 |
* Create a new object of LayoutControl. |
|
131 |
* |
|
132 |
* @param layout |
|
133 |
*/ |
|
134 |
public DefaultLayoutControl() { |
|
135 |
|
|
136 |
} |
|
137 |
|
|
138 |
public void initialize(LayoutPanel layoutPanel){ |
|
139 |
layoutDraw = new FLayoutDraw(layoutPanel); |
|
140 |
layoutEvents = new LayoutEvents(layoutPanel); |
|
141 |
layoutZooms = new FLayoutZooms(layoutPanel); |
|
142 |
layoutFunctions = new FLayoutFunctions(layoutPanel); |
|
143 |
addComponentListener(layoutEvents); |
|
144 |
addMouseMotionListener(layoutEvents); |
|
145 |
addMouseListener(layoutEvents); |
|
146 |
|
|
147 |
LayoutPanListenerImpl lpl = new LayoutPanListenerImpl(layoutPanel); |
|
148 |
addLayoutTool("layoutpan", new LayoutMoveBehavior(lpl)); |
|
149 |
|
|
150 |
LayoutZoomInListenerImpl lzil = new LayoutZoomInListenerImpl(layoutPanel); |
|
151 |
addLayoutTool("layoutzoomin", new LayoutZoomBehavior(lzil)); |
|
152 |
|
|
153 |
LayoutZoomOutListenerImpl lzol = new LayoutZoomOutListenerImpl(layoutPanel); |
|
154 |
addLayoutTool("layoutzoomout", new LayoutZoomBehavior(lzol)); |
|
155 |
|
|
156 |
LayoutAddViewListenerImpl lavl = new LayoutAddViewListenerImpl(layoutPanel); |
|
157 |
addLayoutTool("layoutaddview", new LayoutRectangleBehavior(lavl)); |
|
158 |
|
|
159 |
LayoutAddOverViewListenerImpl laovl = |
|
160 |
new LayoutAddOverViewListenerImpl(layoutPanel); |
|
161 |
addLayoutTool("layoutaddoverview", new LayoutRectangleBehavior(laovl)); |
|
162 |
|
|
163 |
LayoutAddPictureListenerImpl lapl = |
|
164 |
new LayoutAddPictureListenerImpl(layoutPanel); |
|
165 |
addLayoutTool("layoutaddpicture", new LayoutRectangleBehavior(lapl)); |
|
166 |
|
|
167 |
LayoutAddNorthListenerImpl lanorthl = |
|
168 |
new LayoutAddNorthListenerImpl(layoutPanel); |
|
169 |
addLayoutTool("layoutaddnorth", new LayoutRectangleBehavior(lanorthl)); |
|
170 |
|
|
171 |
LayoutAddScaleListenerImpl lasl = |
|
172 |
new LayoutAddScaleListenerImpl(layoutPanel); |
|
173 |
addLayoutTool("layoutaddscale", new LayoutRectangleBehavior(lasl)); |
|
174 |
|
|
175 |
LayoutAddLegendListenerImpl lall = |
|
176 |
new LayoutAddLegendListenerImpl(layoutPanel); |
|
177 |
addLayoutTool("layoutaddlegend", new LayoutRectangleBehavior(lall)); |
|
178 |
|
|
179 |
LayoutAddTextListenerImpl latl = new LayoutAddTextListenerImpl(layoutPanel); |
|
180 |
addLayoutTool("layoutaddtext", new LayoutRectangleBehavior(latl)); |
|
181 |
|
|
182 |
LayoutAddBoxListenerImpl labl = new LayoutAddBoxListenerImpl(layoutPanel); |
|
183 |
addLayoutTool("layoutaddbox", new LayoutRectangleBehavior(labl)); |
|
184 |
|
|
185 |
LayoutAddPointListenerImpl lapointl = |
|
186 |
new LayoutAddPointListenerImpl(layoutPanel); |
|
187 |
addLayoutTool("layoutaddpoint", new LayoutPointBehavior(lapointl)); |
|
188 |
|
|
189 |
LayoutAddLineListenerImpl lalinel = |
|
190 |
new LayoutAddLineListenerImpl(layoutPanel); |
|
191 |
addLayoutTool("layoutaddline", new LayoutPointBehavior(lalinel)); |
|
192 |
|
|
193 |
LayoutAddPolygonListenerImpl lapolygonl = |
|
194 |
new LayoutAddPolygonListenerImpl(layoutPanel); |
|
195 |
addLayoutTool("layoutaddpolygon", new LayoutPointBehavior(lapolygonl)); |
|
196 |
|
|
197 |
LayoutAddPolylineListenerImpl lapolylinel = |
|
198 |
new LayoutAddPolylineListenerImpl(layoutPanel); |
|
199 |
addLayoutTool("layoutaddpolyline", new LayoutPointBehavior(lapolylinel)); |
|
200 |
|
|
201 |
LayoutAddCircleListenerImpl lacirclel = |
|
202 |
new LayoutAddCircleListenerImpl(layoutPanel); |
|
203 |
addLayoutTool("layoutaddcircle", new LayoutPointBehavior(lacirclel)); |
|
204 |
|
|
205 |
LayoutAddRectangleListenerImpl larectanglel = |
|
206 |
new LayoutAddRectangleListenerImpl(layoutPanel); |
|
207 |
addLayoutTool("layoutaddrectangle", new LayoutPointBehavior( |
|
208 |
larectanglel)); |
|
209 |
|
|
210 |
LayoutViewPanListenerImpl lvpl = new LayoutViewPanListenerImpl(layoutPanel); |
|
211 |
addLayoutTool("layoutviewpan", new LayoutViewMoveBehavior(lvpl)); |
|
212 |
|
|
213 |
LayoutViewZoomInListenerImpl lvzil = |
|
214 |
new LayoutViewZoomInListenerImpl(layoutPanel); |
|
215 |
addLayoutTool("layoutviewzoomin", new LayoutViewZoomBehavior(lvzil)); |
|
216 |
|
|
217 |
LayoutViewZoomOutListenerImpl lvzol = |
|
218 |
new LayoutViewZoomOutListenerImpl(layoutPanel); |
|
219 |
addLayoutTool("layoutviewzoomout", new LayoutViewZoomBehavior(lvzol)); |
|
220 |
|
|
221 |
LayoutSelectListenerImpl lselectl = |
|
222 |
new LayoutSelectListenerImpl(layoutPanel); |
|
223 |
addLayoutTool("layoutselect", new LayoutSelectBehavior(lselectl)); |
|
224 |
|
|
225 |
LayoutEditGraphicsListenerImpl leditl = |
|
226 |
new LayoutEditGraphicsListenerImpl(layoutPanel); |
|
227 |
addLayoutTool("layoutedit", new LayoutEditBehavior(leditl)); |
|
228 |
} |
|
229 |
|
|
230 |
public String getCurrentTool() { |
|
231 |
return currentTool; |
|
232 |
} |
|
233 |
|
|
234 |
public void addLayoutTool(String name, LayoutBehavior tool) { |
|
235 |
namesLayoutTools.put(name, tool); |
|
236 |
tool.setLayoutControl(this); |
|
237 |
} |
|
238 |
|
|
239 |
public void setLayoutContext(LayoutContext lc) { |
|
240 |
layoutContext = lc; |
|
241 |
layoutContext.addObserver(this); |
|
242 |
} |
|
243 |
|
|
244 |
/** |
|
245 |
* paintComponent of Layout. |
|
246 |
* |
|
247 |
* @param g |
|
248 |
* Graphics of Layout. |
|
249 |
*/ |
|
250 |
protected void paintComponent(Graphics g) { |
|
251 |
clipVisibleRect((Graphics2D) g); |
|
252 |
|
|
253 |
Rectangle rClip = g.getClipBounds(); |
|
254 |
|
|
255 |
if (rClip == null) { |
|
256 |
System.err.println("clip = null"); |
|
257 |
} |
|
258 |
|
|
259 |
switch (status) { |
|
260 |
case DESACTUALIZADO: |
|
261 |
if (getWidth() == 0) { |
|
262 |
return; |
|
263 |
} |
|
264 |
|
|
265 |
img = |
|
266 |
new BufferedImage(getWidth(), getHeight(), |
|
267 |
BufferedImage.TYPE_INT_ARGB); |
|
268 |
imgRuler = |
|
269 |
new BufferedImage(getWidth(), getHeight(), |
|
270 |
BufferedImage.TYPE_INT_ARGB); |
|
271 |
|
|
272 |
Graphics gimag = img.getGraphics(); |
|
273 |
Graphics gimgRuler = imgRuler.getGraphics(); |
|
274 |
clipVisibleRect((Graphics2D) gimag); |
|
275 |
|
|
276 |
if (initial) { |
|
277 |
fullRect(); |
|
278 |
initial = false; |
|
279 |
} |
|
280 |
|
|
281 |
try { |
|
282 |
layoutDraw.drawLayout((Graphics2D) gimag, img); |
|
283 |
} catch (ReadException e) { |
|
284 |
e.printStackTrace(); |
|
285 |
} |
|
286 |
|
|
287 |
g.setClip(rClip); |
|
288 |
layoutDraw.drawRectangle((Graphics2D) g); |
|
289 |
|
|
290 |
g.drawImage(img, 0, 0, this); |
|
291 |
g.setClip(rClip); |
|
292 |
|
|
293 |
layoutDraw.drawGrid((Graphics2D) gimgRuler); |
|
294 |
layoutDraw.drawRuler((Graphics2D) gimgRuler, Color.black); |
|
295 |
setStatus(ACTUALIZADO); |
|
296 |
repaint(); |
|
297 |
|
|
298 |
break; |
|
299 |
|
|
300 |
case ACTUALIZADO: |
|
301 |
layoutDraw.drawRectangle((Graphics2D) g); |
|
302 |
|
|
303 |
if (currentLayoutTool != null) { |
|
304 |
currentLayoutTool.paintComponent(g); |
|
305 |
} else { |
|
306 |
g.drawImage(img, 0, 0, this); |
|
307 |
|
|
308 |
layoutDraw.drawHandlers((Graphics2D) g, Color.black); |
|
309 |
} |
|
310 |
|
|
311 |
g.setClip(rClip); |
|
312 |
drawCursor(g); |
|
313 |
} |
|
314 |
} |
|
315 |
|
|
316 |
private void setStatus(int s) { |
|
317 |
status = s; |
|
318 |
} |
|
319 |
|
|
320 |
/** |
|
321 |
* Clip on visible rectangle. |
|
322 |
* |
|
323 |
* @param g2d |
|
324 |
* Graphics. |
|
325 |
*/ |
|
326 |
private void clipVisibleRect(Graphics2D g2d) { |
|
327 |
rectVisible = this.getVisibleRect(); |
|
328 |
g2d.clipRect((int) rectVisible.getMinX(), (int) rectVisible.getMinY(), |
|
329 |
(int) rectVisible.getWidth(), (int) rectVisible.getHeight()); |
|
330 |
} |
|
331 |
|
|
332 |
public BufferedImage getImgRuler() { |
|
333 |
return imgRuler; |
|
334 |
} |
|
335 |
|
|
336 |
public void fullRect() { |
|
337 |
rect.setRect(origin.x, origin.y, getWidth() - (origin.x * 2), |
|
338 |
getHeight() - (origin.x * 2)); |
|
339 |
|
|
340 |
if (layoutContext.getAttributes().isLandscape()) { |
|
341 |
rect = |
|
342 |
layoutContext.getAttributes().getRectangleLandscape(rect, |
|
343 |
getWidth(), getHeight()); |
|
344 |
} else { |
|
345 |
rect = |
|
346 |
layoutContext.getAttributes().getRectanglePortrait(rect, |
|
347 |
getWidth(), getHeight()); |
|
348 |
} |
|
349 |
|
|
350 |
refresh(); |
|
351 |
} |
|
352 |
|
|
353 |
public Rectangle2D.Double getRect() { |
|
354 |
return rect; |
|
355 |
} |
|
356 |
|
|
357 |
public void setRect(Rectangle2D r) { |
|
358 |
rect.setRect(r); |
|
359 |
} |
|
360 |
|
|
361 |
public BufferedImage getImage() { |
|
362 |
return img; |
|
363 |
} |
|
364 |
|
|
365 |
/** |
|
366 |
* Draw the cursor on the Graphics. |
|
367 |
* |
|
368 |
* @param g |
|
369 |
* Graphics. |
|
370 |
*/ |
|
371 |
private void drawCursor(Graphics g) { |
|
372 |
if ((imageCursor != null) && (position != null)) { |
|
373 |
Point pAdjusted = position; |
|
374 |
g.drawImage(imageCursor, (int) pAdjusted.getX() - 16, |
|
375 |
(int) pAdjusted.getY() - 16, this); |
|
376 |
} |
|
377 |
} |
|
378 |
|
|
379 |
public void setMapCursor(Image image) { |
|
380 |
imageCursor = image; |
|
381 |
} |
|
382 |
|
|
383 |
public void setTool(String toolName) { |
|
384 |
// prevTool=getCurrentTool(); |
|
385 |
LayoutBehavior layoutTool = |
|
386 |
(LayoutBehavior) namesLayoutTools.get(toolName); |
|
387 |
currentLayoutTool = layoutTool; |
|
388 |
currentLayoutTool.setLayoutControl(this); |
|
389 |
currentTool = toolName; |
|
390 |
this.setMapCursor(layoutTool.getImageCursor()); |
|
391 |
|
|
392 |
if (getCurrentLayoutTool().getListener() instanceof ILayoutGraphicListener) { |
|
393 |
geometryAdapter = |
|
394 |
((ILayoutGraphicListener) getCurrentLayoutTool().getListener()) |
|
395 |
.createGeometryAdapter(); |
|
396 |
} |
|
397 |
|
|
398 |
if (getCurrentTool().equals("layoutedit")) { |
|
399 |
startEdit(); |
|
400 |
} else { |
|
401 |
stopEdit(); |
|
402 |
} |
|
403 |
} |
|
404 |
|
|
405 |
public void startEdit() { |
|
406 |
IFFrame[] fframes = layoutContext.getFFrames(); |
|
407 |
|
|
408 |
for (int i = 0; i < fframes.length; i++) { |
|
409 |
IFFrame frame = fframes[i]; |
|
410 |
|
|
411 |
if (frame instanceof IFFrameEditableVertex) { |
|
412 |
if (frame.getSelected() != IFFrame.NOSELECT) { |
|
413 |
((IFFrameEditableVertex) frame).startEditing(); |
|
414 |
} else { |
|
415 |
((IFFrameEditableVertex) frame).stopEditing(); |
|
416 |
} |
|
417 |
} |
|
418 |
} |
|
419 |
|
|
420 |
refresh(); |
|
421 |
} |
|
422 |
|
|
423 |
public void stopEdit() { |
|
424 |
boolean refresh = false; |
|
425 |
IFFrame[] fframes = layoutContext.getFFrames(); |
|
426 |
|
|
427 |
for (int i = 0; i < fframes.length; i++) { |
|
428 |
IFFrame frame = fframes[i]; |
|
429 |
|
|
430 |
if (frame instanceof IFFrameEditableVertex) { |
|
431 |
if (((IFFrameEditableVertex) frame).isEditing()) { |
|
432 |
((IFFrameEditableVertex) fframes[i]).stopEditing(); |
|
433 |
refresh = true; |
|
434 |
} |
|
435 |
} |
|
436 |
} |
|
437 |
|
|
438 |
if (refresh) { |
|
439 |
refresh(); |
|
440 |
} |
|
441 |
} |
|
442 |
|
|
443 |
public Point getRectOrigin() { |
|
444 |
return rectOrigin; |
|
445 |
} |
|
446 |
|
|
447 |
public FLayoutDraw getLayoutDraw() { |
|
448 |
return layoutDraw; |
|
449 |
} |
|
450 |
|
|
451 |
public LayoutBehavior getCurrentLayoutTool() { |
|
452 |
return currentLayoutTool; |
|
453 |
} |
|
454 |
|
|
455 |
public Point getFirstPoint() { |
|
456 |
return m_FirstPoint; |
|
457 |
} |
|
458 |
|
|
459 |
public Point getPointAnt() { |
|
460 |
return m_PointAnt; |
|
461 |
} |
|
462 |
|
|
463 |
public Point getLastPoint() { |
|
464 |
return m_LastPoint; |
|
465 |
} |
|
466 |
|
|
467 |
public void setFirstPoint() { |
|
468 |
m_FirstPoint = position; |
|
469 |
} |
|
470 |
|
|
471 |
public void setPointAnt() { |
|
472 |
m_PointAnt = position; |
|
473 |
} |
|
474 |
|
|
475 |
public void setLastPoint() { |
|
476 |
m_LastPoint = position; |
|
477 |
} |
|
478 |
|
|
479 |
public void setPosition(Point point2) { |
|
480 |
if (layoutContext.isAdjustingToGrid() |
|
481 |
&& getCurrentLayoutTool().isAdjustable()) { |
|
482 |
position = |
|
483 |
FLayoutUtilities.getPointGrid(point2, layoutContext |
|
484 |
.getAttributes().getNumUnitsX(), layoutContext |
|
485 |
.getAttributes().getNumUnitsY(), layoutContext.getAT()); |
|
486 |
} else { |
|
487 |
position = point2; |
|
488 |
} |
|
489 |
} |
|
490 |
|
|
491 |
public Point getPosition() { |
|
492 |
return position; |
|
493 |
} |
|
494 |
|
|
495 |
public AffineTransform getAT() { |
|
496 |
return layoutContext.getAT(); |
|
497 |
} |
|
498 |
|
|
499 |
public GeometryAdapter getGeometryAdapter() { |
|
500 |
return geometryAdapter; |
|
501 |
} |
|
502 |
|
|
503 |
public void delLastPoint() { |
|
504 |
getGeometryAdapter().delLastPoint(); |
|
505 |
} |
|
506 |
|
|
507 |
public int addGeometryAdapterPoint() { |
|
508 |
return getGeometryAdapter().addPoint( |
|
509 |
FLayoutUtilities.toSheetPoint(getPosition(), getAT())); |
|
510 |
} |
|
511 |
|
|
512 |
public void setGeometryAdapterPoinPosition() { |
|
513 |
getGeometryAdapter().pointPosition( |
|
514 |
FLayoutUtilities.toSheetPoint(getPosition(), getAT())); |
|
515 |
} |
|
516 |
|
|
517 |
public void clearMouseImage() { |
|
518 |
setCursor(transparentCursor); |
|
519 |
} |
|
520 |
|
|
521 |
public void refresh() { |
|
522 |
setStatus(DESACTUALIZADO); |
|
523 |
repaint(); |
|
524 |
} |
|
525 |
|
|
526 |
public synchronized boolean isDrawingCancelled() { |
|
527 |
return m_bCancelDrawing; |
|
528 |
} |
|
529 |
|
|
530 |
public synchronized void setCancelDrawing(boolean b) { |
|
531 |
m_bCancelDrawing = b; |
|
532 |
|
|
533 |
for (int i = 0; i < layoutContext.getFFrames().length; i++) { |
|
534 |
IFFrame fframe = layoutContext.getFFrame(i); |
|
535 |
|
|
536 |
if (fframe instanceof IFFrameUseFMap |
|
537 |
&& (((IFFrameUseFMap) fframe).getMapContext() != null)) { |
|
538 |
// //TODO((FFrameView) |
|
539 |
// getFFrames().get(i)).getFMap().setCancelDrawing(b); |
|
540 |
} |
|
541 |
} |
|
542 |
} |
|
543 |
|
|
544 |
public Rectangle getReSel() { |
|
545 |
return reSel; |
|
546 |
} |
|
547 |
|
|
548 |
public boolean isReSel() { |
|
549 |
return isReSel; |
|
550 |
} |
|
551 |
|
|
552 |
public void setIsReSel(boolean b) { |
|
553 |
isReSel = b; |
|
554 |
} |
|
555 |
|
|
556 |
public void viewFull() throws ReadException { |
|
557 |
IFFrame[] fframes = layoutContext.getFFrameSelected(); |
|
558 |
|
|
559 |
for (int i = 0; i < fframes.length; i++) { |
|
560 |
if (fframes[i] instanceof IFFrameUseFMap) { |
|
561 |
IFFrameUseFMap fframe = (IFFrameUseFMap) fframes[i]; |
|
562 |
|
|
563 |
if (fframe.getMapContext() != null) { |
|
564 |
fframe.fullExtent(); |
|
565 |
} |
|
566 |
|
|
567 |
fframe.refresh(); |
|
568 |
} |
|
569 |
} |
|
570 |
|
|
571 |
refresh(); |
|
572 |
} |
|
573 |
|
|
574 |
public FLayoutZooms getLayoutZooms() { |
|
575 |
return layoutZooms; |
|
576 |
} |
|
577 |
|
|
578 |
public FLayoutFunctions getLayoutFunctions() { |
|
579 |
return layoutFunctions; |
|
580 |
} |
|
581 |
|
|
582 |
public LayoutContext getLayoutContext() { |
|
583 |
return layoutContext; |
|
584 |
} |
|
585 |
|
|
586 |
public void setGeometryAdapter(GeometryAdapter adapter) { |
|
587 |
geometryAdapter = adapter; |
|
588 |
} |
|
589 |
|
|
590 |
public JComponent getComponent() { |
|
591 |
return this; |
|
592 |
} |
|
593 |
|
|
594 |
public void update(Observable observable, Object notification) { |
|
595 |
if ((notification != null) && (notification instanceof LayoutNotification)){ |
|
596 |
LayoutNotification layoutNotification = (LayoutNotification)notification; |
|
597 |
if (LayoutNotification.LAYOUT_VALIDATED.equals(layoutNotification.getType())){ |
|
598 |
status = ACTUALIZADO; |
|
599 |
}else if (LayoutNotification.LAYOUT_INVALIDATED.equals(layoutNotification.getType())){ |
|
600 |
status = DESACTUALIZADO; |
|
601 |
}else if (LayoutNotification.LAYOUT_REFRESH.equals(layoutNotification.getType())){ |
|
602 |
refresh(); |
|
603 |
} |
|
604 |
} |
|
605 |
} |
|
606 |
} |
tags/org.gvsig.app.document.layout.app-2.0.21/org.gvsig.app.document.layout.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/LayoutNotification.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; |
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
/** |
|
27 |
* @author gvSIG Team |
|
28 |
* @version $Id$ |
|
29 |
* |
|
30 |
*/ |
|
31 |
public interface LayoutNotification { |
|
32 |
/** Fired when the layout has to be repainted */ |
|
33 |
public static final String LAYOUT_INVALIDATED = "layout_invalidated"; |
|
34 |
|
|
35 |
/** Fired when the layout doesn't have to be repainted */ |
|
36 |
public static final String LAYOUT_VALIDATED = "layout_validated"; |
|
37 |
|
|
38 |
/** Fired when the layout doesn't have to be repainted */ |
|
39 |
public static final String LAYOUT_REFRESH = "layout_refresh"; |
|
40 |
|
|
41 |
/** |
|
42 |
* Returns the type of this notification, represented by one of the constants defined in this interface. |
|
43 |
* @return a String containing this notification's type |
|
44 |
*/ |
|
45 |
public String getType(); |
|
46 |
} |
tags/org.gvsig.app.document.layout.app-2.0.21/org.gvsig.app.document.layout.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/Attributes.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; |
|
23 |
|
|
24 |
import java.awt.Rectangle; |
|
25 |
import java.awt.geom.Point2D; |
|
26 |
import java.awt.geom.Rectangle2D; |
|
27 |
import java.awt.print.PageFormat; |
|
28 |
import java.awt.print.Paper; |
|
29 |
import java.text.NumberFormat; |
|
30 |
|
|
31 |
import javax.print.attribute.HashPrintRequestAttributeSet; |
|
32 |
import javax.print.attribute.PrintRequestAttributeSet; |
|
33 |
import javax.print.attribute.standard.Copies; |
|
34 |
import javax.print.attribute.standard.Fidelity; |
|
35 |
import javax.print.attribute.standard.Media; |
|
36 |
import javax.print.attribute.standard.MediaPrintableArea; |
|
37 |
import javax.print.attribute.standard.MediaSizeName; |
|
38 |
import javax.print.attribute.standard.OrientationRequested; |
|
39 |
import javax.print.attribute.standard.PrintQuality; |
|
40 |
import javax.print.attribute.standard.Sides; |
|
41 |
|
|
42 |
import org.gvsig.andami.PluginServices; |
|
43 |
import org.gvsig.compat.CompatLocator; |
|
44 |
import org.gvsig.compat.print.PrintAttributes; |
|
45 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
46 |
import org.gvsig.tools.ToolsLocator; |
|
47 |
import org.gvsig.tools.dynobject.DynStruct; |
|
48 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
49 |
import org.gvsig.tools.persistence.Persistent; |
|
50 |
import org.gvsig.tools.persistence.PersistentState; |
|
51 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
|
52 |
import org.gvsig.utils.XMLEntity; |
|
53 |
|
|
54 |
/** |
|
55 |
* Attributes of Layout. |
|
56 |
* |
|
57 |
* @author Vicente Caballero Navarro |
|
58 |
* @author jldominguez |
|
59 |
*/ |
|
60 |
public class Attributes implements Persistent { |
|
61 |
|
|
62 |
public static final String PERSISTENCE_DEFINITION_NAME = "Attributes"; |
|
63 |
public static final String DPI_FIELD = "DPI"; |
|
64 |
public static final String DPISCREEN_FIELD = "DPISCREEN"; |
|
65 |
public static final String TYPEUNIT_FIELD = "typeUnit"; |
|
66 |
public static final String NUMX_FIELD = "numX"; |
|
67 |
public static final String NUMY_FIELD = "numY"; |
|
68 |
public static final String UNITX_FIELD = "unitX"; |
|
69 |
public static final String UNITY_FIELD = "unitY"; |
|
70 |
public static final String HASMARGIN_FIELD = "hasMargin"; |
|
71 |
public static final String RESOLUTIONSEL_FIELD = "resolutionSel"; |
|
72 |
public static final String TYPESEL_FIELD = "typeSel"; |
|
73 |
public static final String SELTYPEUNIT_FIELD = "selTypeUnit"; |
|
74 |
public static final String SIZEPAPER_FIELD = "sizePaper"; |
|
75 |
public static final String AREA_FIELD = "area"; |
|
76 |
// public static final String WIDTHXHEIGHT_FIELD = "widthXHeight"; |
|
77 |
public static final String SIZEINUNITS_FIELD = "sizeInUnits"; |
|
78 |
public static final String ISLANDSEL_FIELD = "isLandSel"; |
|
79 |
|
|
80 |
/** |
|
81 |
* Array of doubles containg the change factro from <b>CENTIMETERS</b> to |
|
82 |
* KILOMETERS, METERS, CENTIMETERS, MILLIMETERS, MILES, YARDS, FEET, INCHES, |
|
83 |
* DECIMAL DEGREES |
|
84 |
*/ |
|
85 |
/* |
|
86 |
* Do not alter the order and the values of this array, if you need append |
|
87 |
* values. |
|
88 |
*/ |
|
89 |
public static final double[] CHANGE = { 100000, 100, 1, 0.1, 160934.4, |
|
90 |
91.44, 30.48, 2.54, 8.983152841195214E-6 }; |
|
91 |
public static final String DEGREES = "Grados"; |
|
92 |
/* |
|
93 |
* Do not alter the order and the values of this array, if you need append |
|
94 |
* values. |
|
95 |
*/ |
|
96 |
public static final double[] UNIT = { 0.0000025, 0.0025, 0.25, 2.5, |
|
97 |
0.0000025, 0.025, 0.025, 0.25, 8.8E-7 }; |
|
98 |
public static final int HIGH = 0; |
|
99 |
public static final int NORMAL = 1; |
|
100 |
public static final int DRAFT = 2; |
|
101 |
|
|
102 |
// Para impresi?n |
|
103 |
public final static double PULGADA = 2.54; |
|
104 |
|
|
105 |
// public final static Size CUSTOM_PAPER_SIZE = new Size(8.5, 11.0); |
|
106 |
public final static Size STANDARD_LETTER_PAPER_SIZE = new Size(8.5, 11.0); |
|
107 |
public final static Size STANDARD_FOLIO_PAPER_SIZE = new Size(8.5, 13.0); |
|
108 |
public final static Size STANDARD_LEGAL_PAPER_SIZE = new Size(8.5, 14.0); |
|
109 |
public final static Size STANDARD_TABLOID_PAPER_SIZE = new Size(11.0, 17.0); |
|
110 |
public final static Size METRIC_A0_PAPER_SIZE = new Size(118.9, 84.1); |
|
111 |
public final static Size METRIC_A1_PAPER_SIZE = new Size(84.1, 59.4); |
|
112 |
public final static Size METRIC_A2_PAPER_SIZE = new Size(59.4, 42.0); |
|
113 |
public final static Size METRIC_A3_PAPER_SIZE = new Size(42.0, 29.7); |
|
114 |
public final static Size METRIC_A4_PAPER_SIZE = new Size(29.7, 21.0); |
|
115 |
public final static Size METRIC_A5_PAPER_SIZE = new Size(21.0, 14.8); |
|
116 |
public final static Size ANSI_ENG_A_PAPER_SIZE = new Size(11.0, 8.5); |
|
117 |
public final static Size ANSI_ENG_B_PAPER_SIZE = new Size(17.0, 11.0); |
|
118 |
public final static Size ANSI_ENG_C_PAPER_SIZE = new Size(22.0, 17.0); |
|
119 |
public final static Size ANSI_ENG_D_PAPER_SIZE = new Size(34.0, 22.0); |
|
120 |
public final static Size ANSI_ENG_E_PAPER_SIZE = new Size(44.0, 34.0); |
|
121 |
public final static Size ANSI_ARCH_A_PAPER_SIZE = new Size(12.0, 9.0); |
|
122 |
public final static Size ANSI_ARCH_B_PAPER_SIZE = new Size(18.0, 12.0); |
|
123 |
public final static Size ANSI_ARCH_C_PAPER_SIZE = new Size(24.0, 18.0); |
|
124 |
public final static Size ANSI_ARCH_D_PAPER_SIZE = new Size(36.0, 24.0); |
|
125 |
public final static Size ANSI_ARCH_E_PAPER_SIZE = new Size(42.0, 30.0); |
|
126 |
|
|
127 |
/** |
|
128 |
* CUSTOM_PAPER_SIZE does not know about portrait/landscape |
|
129 |
* (same as other PAPER constants) |
|
130 |
*/ |
|
131 |
public static Size CUSTOM_PAPER_SIZE = new Size(100.0, 100.0); |
|
132 |
|
|
133 |
public final static int PRINT = 0; |
|
134 |
public final static int CUSTOM = 6; |
|
135 |
public final static int A0 = 5; |
|
136 |
public final static int A1 = 4; |
|
137 |
public final static int A2 = 3; |
|
138 |
public final static int A3 = 2; |
|
139 |
public final static int A4 = 1; |
|
140 |
public static int DPI = 300; |
|
141 |
public static int DPISCREEN = 72; |
|
142 |
private static Point2D defaultGridGap; |
|
143 |
|
|
144 |
private PrintRequestAttributeSet attributes = |
|
145 |
new HashPrintRequestAttributeSet(); |
|
146 |
private MediaSizeName m_type = MediaSizeName.ISO_A4; |
|
147 |
private OrientationRequested m_Orientation; |
|
148 |
private double m_TypeUnit = CHANGE[2]; // CENTIMETROS; |
|
149 |
private String m_NameUnit; |
|
150 |
private Double m_numX = null; |
|
151 |
private Double m_numY = null; |
|
152 |
private double m_unitX = 0; |
|
153 |
private double m_unitY = 0; |
|
154 |
private boolean hasmargin; |
|
155 |
private int m_resolutionSel = NORMAL; |
|
156 |
private int m_typeSel = PRINT; |
|
157 |
private int m_selTypeUnit = 2; |
|
158 |
|
|
159 |
/** |
|
160 |
* This field does not change when it's landscape |
|
161 |
* (it does not "know" about portrait/landscape) |
|
162 |
*/ |
|
163 |
public Size m_sizePaper = new Size( |
|
164 |
METRIC_A4_PAPER_SIZE.getAlto(), |
|
165 |
METRIC_A4_PAPER_SIZE.getAncho()); |
|
166 |
|
|
167 |
/** |
|
168 |
* Print area (top, bottom, left, right). |
|
169 |
* This array changes when it's landscape |
|
170 |
* (it "knows" about portrait/landscape) |
|
171 |
*/ |
|
172 |
private double[] area_tblr = { |
|
173 |
0, |
|
174 |
0, |
|
175 |
0, |
|
176 |
0 }; |
|
177 |
|
|
178 |
/** |
|
179 |
* This field changes when it's landscape |
|
180 |
* (it "knows" about portrait/landscape) |
|
181 |
*/ |
|
182 |
private Size m_sizeinUnits = m_sizePaper; |
|
183 |
private PrintQuality m_resolution = PrintQuality.NORMAL; |
|
184 |
|
|
185 |
/** |
|
186 |
* Create a new object of Attributes. |
|
187 |
* |
|
188 |
*/ |
|
189 |
public Attributes() { |
|
190 |
m_NameUnit = PluginServices.getText(this, "Centimetros"); |
|
191 |
m_Orientation = OrientationRequested.LANDSCAPE; |
|
192 |
m_type = MediaSizeName.ISO_A4; |
|
193 |
resetSizeinUnits(isLandscape()); |
|
194 |
|
|
195 |
hasmargin = false; |
|
196 |
attributes.add(new Copies(1)); |
|
197 |
attributes.add(MediaSizeName.ISO_A4); |
|
198 |
attributes.add(Sides.ONE_SIDED); |
|
199 |
attributes.add(Fidelity.FIDELITY_FALSE); |
|
200 |
attributes.add(PrintQuality.NORMAL); |
|
201 |
|
|
202 |
setType(m_typeSel); |
|
203 |
|
|
204 |
if (isLandscape()) { |
|
205 |
attributes.add(new MediaPrintableArea(0, 0, |
|
206 |
(float) ((m_sizePaper.getAlto() * DPISCREEN) / PULGADA), |
|
207 |
(float) ((m_sizePaper.getAncho() * DPISCREEN) / PULGADA), |
|
208 |
MediaPrintableArea.MM)); |
|
209 |
} else { |
|
210 |
attributes.add(new MediaPrintableArea(0, 0, |
|
211 |
(float) ((m_sizePaper.getAncho() * DPISCREEN) / PULGADA), |
|
212 |
(float) ((m_sizePaper.getAlto() * DPISCREEN) / PULGADA), |
|
213 |
MediaPrintableArea.MM)); |
|
214 |
} |
|
215 |
} |
|
216 |
|
|
217 |
|
|
218 |
|
|
219 |
/** |
|
220 |
* @return |
|
221 |
*/ |
|
222 |
public boolean isLandscape() { |
|
223 |
return m_Orientation.getValue() == |
|
224 |
OrientationRequested.LANDSCAPE.getValue(); |
|
225 |
} |
|
226 |
|
|
227 |
/** |
|
228 |
* Inserts the Layout's properties to print. |
|
229 |
* |
|
230 |
* @param typeSel |
|
231 |
* Type of sheet. |
|
232 |
* @param units |
|
233 |
* Units. |
|
234 |
* @param isLand |
|
235 |
* True if the sheet is horizontal. |
|
236 |
* @param margin |
|
237 |
* True if the sheet has margin. |
|
238 |
* @param resolution |
|
239 |
* Type of quality of resolution. |
|
240 |
* @param area |
|
241 |
* Printing area (top, bottom, left, right). |
|
242 |
*/ |
|
243 |
public void setSelectedOptions(int typeSel, int units, boolean isLand, |
|
244 |
boolean margin, int resolution, double[] _area_tplr) { |
|
245 |
setType(typeSel); |
|
246 |
setUnit(units); |
|
247 |
setIsLandScape(isLand); |
|
248 |
hasmargin = margin; |
|
249 |
setResolution(resolution); |
|
250 |
area_tblr = _area_tplr; |
|
251 |
} |
|
252 |
|
|
253 |
/** |
|
254 |
* This field does not know about orientation. |
|
255 |
* It's value is the same for portrait and landscape |
|
256 |
* |
|
257 |
* @return |
|
258 |
*/ |
|
259 |
public Size getPaperSize() { |
|
260 |
return m_sizePaper; |
|
261 |
} |
|
262 |
|
|
263 |
/** |
|
264 |
* Returns a PageFormat with the properties of printing. |
|
265 |
* |
|
266 |
* @return PageFormat |
|
267 |
*/ |
|
268 |
public PageFormat getPageFormat() { |
|
269 |
PageFormat pf1 = new PageFormat(); |
|
270 |
Paper paper = pf1.getPaper(); |
|
271 |
|
|
272 |
paper.setSize( |
|
273 |
(m_sizePaper.getAncho() * DPISCREEN) / PULGADA, |
|
274 |
(m_sizePaper.getAlto() * DPISCREEN) / PULGADA); |
|
275 |
|
|
276 |
if (isLandscape()) { |
|
277 |
pf1.setOrientation(0); |
|
278 |
/* |
|
279 |
* 'area_tblr' and 'm_sizeinUnits' depend on |
|
280 |
* whether it is portrait or landscape, but |
|
281 |
* 'Paper' and 'm_sizePaper' must not know if it's |
|
282 |
* portrait/landscape, so we change order of |
|
283 |
* parameters. 'PageFormat' will do the changes again |
|
284 |
* because it is aware of portrait/landscape |
|
285 |
*/ |
|
286 |
paper.setImageableArea( |
|
287 |
getInPixels(area_tblr[1]), |
|
288 |
getInPixels(area_tblr[2]), |
|
289 |
getInPixels(m_sizeinUnits.getAlto() - area_tblr[0] - area_tblr[1]), |
|
290 |
getInPixels(m_sizeinUnits.getAncho() - area_tblr[2] - area_tblr[3])); |
|
291 |
} else { |
|
292 |
// portrait |
|
293 |
pf1.setOrientation(1); |
|
294 |
paper.setImageableArea( |
|
295 |
getInPixels(area_tblr[2]), |
|
296 |
getInPixels(area_tblr[0]), |
|
297 |
getInPixels(m_sizeinUnits.getAncho() - area_tblr[2] - area_tblr[3]), |
|
298 |
getInPixels(m_sizeinUnits.getAlto() - area_tblr[0] - area_tblr[1])); |
|
299 |
} |
|
300 |
|
|
301 |
pf1.setPaper(paper); |
|
302 |
return pf1; |
|
303 |
} |
|
304 |
|
|
305 |
/** |
|
306 |
* Changes centimeters to pixels. |
|
307 |
* |
|
308 |
* @param d |
|
309 |
* Centimeters. |
|
310 |
* |
|
311 |
* @return Pixels. |
|
312 |
*/ |
|
313 |
private double getInPixels(double d) { |
|
314 |
return d * (DPISCREEN / PULGADA); |
|
315 |
} |
|
316 |
|
|
317 |
/** |
|
318 |
* Changes pixels to centimeters. |
|
319 |
* |
|
320 |
* @param d |
|
321 |
* Pixel. |
|
322 |
* |
|
323 |
* @return Centimeters. |
|
324 |
*/ |
|
325 |
private double getInCM(double d) { |
Also available in: Unified diff