Revision 1061
tags/org.gvsig.app.document.layout2.app-2.0.176/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.176</version> |
|
7 |
|
|
8 |
<name>${project.artifactId}</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.307</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.176</connection> |
|
21 |
<developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-app-document-layout/tags/org.gvsig.app.document.layout2.app-2.0.176</developerConnection> |
|
22 |
<url>https://devel.gvsig.org/redmine/projects/gvsig-app-document-layout/repository/show/tags/org.gvsig.app.document.layout2.app-2.0.176</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 |
<dependencyManagement> |
|
55 |
<dependencies> |
|
56 |
<!-- |
|
57 |
Versions of child projects |
|
58 |
--> |
|
59 |
<dependency> |
|
60 |
<groupId>org.gvsig</groupId> |
|
61 |
<artifactId>org.gvsig.app.document.layout2.app.mainplugin</artifactId> |
|
62 |
<version>2.0.176</version> |
|
63 |
</dependency> |
|
64 |
|
|
65 |
</dependencies> |
|
66 |
</dependencyManagement> |
|
67 |
|
|
68 |
<modules> |
|
69 |
<module>org.gvsig.app.document.layout2.app.mainplugin</module> |
|
70 |
</modules> |
|
71 |
|
|
72 |
</project> |
|
0 | 73 |
tags/org.gvsig.app.document.layout2.app-2.0.176/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.176/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.176/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.176/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/FLayoutDraw.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.Component; |
|
26 |
import java.awt.Cursor; |
|
27 |
import java.awt.Graphics; |
|
28 |
import java.awt.Graphics2D; |
|
29 |
import java.awt.geom.AffineTransform; |
|
30 |
import java.awt.geom.Point2D; |
|
31 |
import java.awt.geom.Rectangle2D; |
|
32 |
import java.awt.image.BufferedImage; |
|
33 |
import java.awt.print.PageFormat; |
|
34 |
import java.awt.print.Printable; |
|
35 |
import java.awt.print.PrinterException; |
|
36 |
import java.io.BufferedOutputStream; |
|
37 |
import java.io.File; |
|
38 |
import java.io.FileOutputStream; |
|
39 |
import java.io.IOException; |
|
40 |
import java.io.OutputStream; |
|
41 |
|
|
42 |
import javax.print.Doc; |
|
43 |
import javax.print.DocFlavor; |
|
44 |
import javax.print.DocPrintJob; |
|
45 |
import javax.print.PrintException; |
|
46 |
import javax.print.SimpleDoc; |
|
47 |
import javax.print.StreamPrintService; |
|
48 |
import javax.print.StreamPrintServiceFactory; |
|
49 |
import javax.print.attribute.DocAttributeSet; |
|
50 |
import javax.print.attribute.HashDocAttributeSet; |
|
51 |
import javax.print.attribute.PrintRequestAttributeSet; |
|
52 |
import javax.swing.JOptionPane; |
|
53 |
|
|
54 |
import com.lowagie.text.Document; |
|
55 |
import com.lowagie.text.DocumentException; |
|
56 |
import com.lowagie.text.PageSize; |
|
57 |
import com.lowagie.text.Rectangle; |
|
58 |
import com.lowagie.text.pdf.PdfContentByte; |
|
59 |
import com.lowagie.text.pdf.PdfWriter; |
|
60 |
|
|
61 |
import org.slf4j.Logger; |
|
62 |
import org.slf4j.LoggerFactory; |
|
63 |
import org.gvsig.andami.PluginServices; |
|
64 |
import org.gvsig.app.project.documents.layout.fframes.IFFrame; |
|
65 |
import org.gvsig.app.project.documents.layout.gui.LayoutPanel; |
|
66 |
import org.gvsig.fmap.dal.exception.ReadException; |
|
67 |
import org.gvsig.tools.observer.Observable; |
|
68 |
import org.gvsig.tools.observer.ObservableHelper; |
|
69 |
import org.gvsig.tools.observer.Observer; |
|
70 |
|
|
71 |
/** |
|
72 |
* Clase que implementa los m?todos del Layout que dibujan sobre el Graphics. |
|
73 |
* |
|
74 |
* @author Vicente Caballero Navarro |
|
75 |
*/ |
|
76 |
public class FLayoutDraw implements Observable, Printable{ |
|
77 |
private static final Logger LOG = |
|
78 |
LoggerFactory.getLogger(FLayoutDraw.class); |
|
79 |
|
|
80 |
private LayoutPanel layoutPanel; |
|
81 |
private LayoutControl layoutControl; |
|
82 |
private LayoutContext layoutContext; |
|
83 |
private ObservableHelper observers; |
|
84 |
|
|
85 |
/** |
|
86 |
* Crea un nuevo FLayoutDraw. |
|
87 |
* |
|
88 |
* @param l |
|
89 |
* Referencia al Layout. |
|
90 |
*/ |
|
91 |
public FLayoutDraw(LayoutPanel layoutPanel) { |
|
92 |
this.layoutPanel = layoutPanel; |
|
93 |
observers = new ObservableHelper(); |
|
94 |
observers.addObserver(layoutPanel.getLayoutControl()); |
|
95 |
} |
|
96 |
|
|
97 |
public void initialize(){ |
|
98 |
if ((layoutContext == null) || (layoutControl == null)){ |
|
99 |
this.layoutControl = layoutPanel.getLayoutControl(); |
|
100 |
this.layoutContext = layoutPanel.getLayoutContext(); |
|
101 |
} |
|
102 |
} |
|
103 |
|
|
104 |
/** |
|
105 |
* M?todo para dibujar el Layout y modificar la matriz de transformaci?n a |
|
106 |
* partir del tama?o en pixels que tenga rect y el formato de papel |
|
107 |
* seleccionado. |
|
108 |
* |
|
109 |
* @param g2 |
|
110 |
* @param imgBase |
|
111 |
* Si es null, est?s imprimiendo. Si no, la usas para el |
|
112 |
* c?digo de optimizaci?n. |
|
113 |
* |
|
114 |
* @throws ReadDriverException |
|
115 |
*/ |
|
116 |
public void drawLayout(Graphics2D g2, BufferedImage imgBase) |
|
117 |
throws ReadException { |
|
118 |
if (!initializeAffineTransform()) { |
|
119 |
return; |
|
120 |
} |
|
121 |
|
|
122 |
IFFrame[] fframes = layoutContext.getFFrames(); |
|
123 |
for (int i = 0; i < fframes.length; i++) { |
|
124 |
IFFrame f = fframes[i]; |
|
125 |
f.draw(g2, layoutContext.getAT(), layoutControl.getComponent().getVisibleRect(), |
|
126 |
imgBase); |
|
127 |
|
|
128 |
// Dibuja el s?mbolo de que contiene un tag. |
|
129 |
if ((f.getTag() != null) && (layoutPanel.isShowIconTag())) { |
|
130 |
f.drawSymbolTag(g2); |
|
131 |
} |
|
132 |
} |
|
133 |
|
|
134 |
if (!(fframes.length == 0)) { |
|
135 |
observers.notifyObservers(this, |
|
136 |
new DefaultLayoutNotification(LayoutNotification.LAYOUT_VALIDATED)); |
|
137 |
} else { |
|
138 |
observers.notifyObservers(this, |
|
139 |
new DefaultLayoutNotification(LayoutNotification.LAYOUT_INVALIDATED)); |
|
140 |
} |
|
141 |
} |
|
142 |
|
|
143 |
public boolean initializeAffineTransform(){ |
|
144 |
initialize(); |
|
145 |
AffineTransform at = layoutContext.getAT(); |
|
146 |
Rectangle2D rLayout = layoutControl.getRect(); |
|
147 |
if (rLayout.getHeight()<0) { |
|
148 |
// still not ready to be painted |
|
149 |
return false; |
|
150 |
} |
|
151 |
Attributes attributes = layoutContext.getAttributes(); |
|
152 |
|
|
153 |
layoutControl.setCancelDrawing(false); |
|
154 |
|
|
155 |
double scale = 0; |
|
156 |
scale = rLayout.getHeight() / attributes.getPaperSize().getHeight() * 1; // paper (paper units) to screen (pixels) scale |
|
157 |
AffineTransform escalado = new AffineTransform(); |
|
158 |
AffineTransform translacion = new AffineTransform(); |
|
159 |
translacion.setToTranslation(rLayout.getMinX(), rLayout.getMinY()); |
|
160 |
escalado.setToScale(scale, scale); |
|
161 |
at.setToIdentity(); |
|
162 |
at.concatenate(translacion); |
|
163 |
at.concatenate(escalado); |
|
164 |
attributes.calculateGridGapX(rLayout); |
|
165 |
attributes.calculateGridGapY(rLayout); |
|
166 |
return true; |
|
167 |
} |
|
168 |
|
|
169 |
/** |
|
170 |
* Dibuja sobre un Graphics2D el rect?ngulo que representa al folio. |
|
171 |
* |
|
172 |
* @param g |
|
173 |
* Graphics2D |
|
174 |
*/ |
|
175 |
public void drawRectangle(Graphics2D g) { |
|
176 |
initialize(); |
|
177 |
Attributes attributes = layoutContext.getAttributes(); |
|
178 |
Rectangle2D rLayout = layoutControl.getRect(); |
|
179 |
AffineTransform at = layoutContext.getAT(); |
|
180 |
|
|
181 |
double unidadesX = attributes.getHGridGapCm(); |
|
182 |
double unidadesY = attributes.getVGridGapCm(); |
|
183 |
|
|
184 |
if ((unidadesX == 0) && (unidadesY == 0)) { |
|
185 |
return; |
|
186 |
} |
|
187 |
|
|
188 |
g.setColor(Color.darkGray); |
|
189 |
|
|
190 |
Rectangle2D.Double rectBig = |
|
191 |
new Rectangle2D.Double(rLayout.getX(), rLayout.getY(), |
|
192 |
rLayout.getWidth(), rLayout.getHeight()); |
|
193 |
|
|
194 |
g.fillRect((int) rectBig.x + 7, (int) rectBig.y + 7, |
|
195 |
(int) rectBig.width, (int) rectBig.height); |
|
196 |
|
|
197 |
Rectangle2D.Double r = new Rectangle2D.Double(); |
|
198 |
|
|
199 |
if (attributes.isMargin()) { |
|
200 |
|
|
201 |
r = |
|
202 |
new Rectangle2D.Double( |
|
203 |
(rLayout.getX() + FLayoutUtilities.fromSheetDistance( |
|
204 |
attributes.getAreaInsets()[2], at)), |
|
205 |
(rLayout.getY() + FLayoutUtilities.fromSheetDistance( |
|
206 |
attributes.getAreaInsets()[0], at)), |
|
207 |
(rLayout.getWidth() - FLayoutUtilities.fromSheetDistance( |
|
208 |
attributes.getAreaInsets()[2] + attributes.getAreaInsets()[3], at)), |
|
209 |
(rLayout.getHeight() - FLayoutUtilities.fromSheetDistance( |
|
210 |
attributes.getAreaInsets()[0] + attributes.getAreaInsets()[1], at))); |
|
211 |
} else { |
|
212 |
r.setRect(rLayout); |
|
213 |
} |
|
214 |
|
|
215 |
g.setColor(Color.white); |
|
216 |
g.fill(rLayout); |
|
217 |
|
|
218 |
g.setColor(Color.darkGray); |
|
219 |
g.drawRect((int) rLayout.getMinX(), (int) rLayout.getMinY(), |
|
220 |
(int) rLayout.getWidth(), (int) rLayout.getHeight()); |
|
221 |
|
|
222 |
if (attributes.isMargin()) { |
|
223 |
g.setColor(Color.black); |
|
224 |
|
|
225 |
g.drawRect((int) r.x, (int) r.y, (int) r.width, (int) r.height); |
|
226 |
} |
|
227 |
} |
|
228 |
|
|
229 |
/** |
|
230 |
* DOCUMENT ME! |
|
231 |
* |
|
232 |
* @param g |
|
233 |
* DOCUMENT ME! |
|
234 |
*/ |
|
235 |
public void drawGrid(Graphics2D g) { |
|
236 |
int unidadesMin = 6; |
|
237 |
Attributes attributes = layoutContext.getAttributes(); |
|
238 |
Rectangle2D rLayout = layoutControl.getRect(); |
|
239 |
AffineTransform at = layoutContext.getAT(); |
|
240 |
|
|
241 |
double unidadesX = attributes.getHGridGapPx(); |
|
242 |
double unidadesY = attributes.getVGridGapPx(); |
|
243 |
|
|
244 |
Rectangle2D.Double r = new Rectangle2D.Double(); |
|
245 |
|
|
246 |
if (attributes.isMargin()) { |
|
247 |
r = |
|
248 |
new Rectangle2D.Double( |
|
249 |
(rLayout.getX() + FLayoutUtilities.fromSheetDistance( |
|
250 |
attributes.getAreaInsets()[2], at)), |
|
251 |
(rLayout.getY() + FLayoutUtilities.fromSheetDistance( |
|
252 |
attributes.getAreaInsets()[0], at)), |
|
253 |
(rLayout.getWidth() - FLayoutUtilities.fromSheetDistance( |
|
254 |
attributes.getAreaInsets()[2] + attributes.getAreaInsets()[3], at)), |
|
255 |
(rLayout.getHeight() - FLayoutUtilities.fromSheetDistance( |
|
256 |
attributes.getAreaInsets()[0] + attributes.getAreaInsets()[1], at))); |
|
257 |
} else { |
|
258 |
r.setRect(rLayout); |
|
259 |
} |
|
260 |
if ((unidadesX == 0) && (unidadesY == 0)) { |
|
261 |
return; |
|
262 |
} |
|
263 |
g.setColor(Color.darkGray); |
|
264 |
|
|
265 |
if (((unidadesX > unidadesMin) || (unidadesY > unidadesMin)) |
|
266 |
&& layoutContext.isGridVisible()) { |
|
267 |
double ax = r.getMinX(); |
|
268 |
double ay; |
|
269 |
|
|
270 |
while (ax < (r.getMaxX())) { |
|
271 |
ay = (r.getMinY()); |
|
272 |
|
|
273 |
while (ay < (r.getMaxY())) { |
|
274 |
g.drawLine((int) ax, (int) ay, (int) ax, (int) ay); |
|
275 |
ay = ay + unidadesY; |
|
276 |
} |
|
277 |
|
|
278 |
ax = ax + unidadesX; |
|
279 |
} |
|
280 |
} |
|
281 |
} |
|
282 |
|
|
283 |
/** |
|
284 |
* Dibuja sobre el graphics2d las reglas. |
|
285 |
* |
|
286 |
* @param g |
|
287 |
* graphics2d sobre el que se dibuja. |
|
288 |
* @param color |
|
289 |
* Color de la regla. |
|
290 |
*/ |
|
291 |
public void drawRuler(Graphics2D g, Color color) { |
|
292 |
Attributes attributes = layoutContext.getAttributes(); |
|
293 |
Rectangle2D rLayout = layoutControl.getRect(); |
|
294 |
AffineTransform at = layoutContext.getAT(); |
|
295 |
|
|
296 |
if (layoutContext.getRuler()) { |
|
297 |
int ini = 10; |
|
298 |
int w = 30; |
|
299 |
int wi = 16; |
|
300 |
|
|
301 |
g.setColor(new Color(250, 255, 250, 180)); |
|
302 |
g.fillRect(ini, w, wi, layoutControl.getComponent().getHeight() - w); |
|
303 |
g.fillRect(w, ini, layoutControl.getWidth() - w, wi); |
|
304 |
|
|
305 |
g.setColor(new Color(100, 155, 150, 180)); |
|
306 |
g.fillRect(w, ini, (int) rLayout.getX() - w, wi); |
|
307 |
g.fillRect((int) rLayout.getMaxX(), ini, layoutControl.getWidth() |
|
308 |
- (int) rLayout.getMaxX(), wi); |
|
309 |
|
|
310 |
g.fillRect(ini, w, wi, (int) rLayout.getY() - w); |
|
311 |
g.fillRect(ini, (int) rLayout.getMaxY(), wi, |
|
312 |
layoutControl.getHeight() - (int) rLayout.getMaxY()); |
|
313 |
|
|
314 |
if (attributes.isMargin()) { |
|
315 |
g.setColor(new Color(50, 55, 50, 180)); |
|
316 |
g.fillRect((int) rLayout.getX(), ini, (int) FLayoutUtilities |
|
317 |
.fromSheetDistance(attributes.getAreaInsets()[2], at), wi); |
|
318 |
g.fillRect( |
|
319 |
(int) rLayout.getMaxX() |
|
320 |
- (int) FLayoutUtilities.fromSheetDistance( |
|
321 |
attributes.getAreaInsets()[3], at), ini, |
|
322 |
(int) FLayoutUtilities.fromSheetDistance( |
|
323 |
attributes.getAreaInsets()[3], at), wi); |
|
324 |
|
|
325 |
g.fillRect(ini, (int) rLayout.getY(), wi, |
|
326 |
(int) FLayoutUtilities.fromSheetDistance( |
|
327 |
attributes.getAreaInsets()[0], at)); |
|
328 |
g.fillRect( |
|
329 |
ini, |
|
330 |
(int) rLayout.getMaxY() |
|
331 |
- (int) FLayoutUtilities.fromSheetDistance( |
|
332 |
attributes.getAreaInsets()[1], at), wi, |
|
333 |
(int) FLayoutUtilities.fromSheetDistance( |
|
334 |
attributes.getAreaInsets()[1], at)); |
|
335 |
} |
|
336 |
|
|
337 |
g.setColor(color); |
|
338 |
g.drawLine(w, wi + ini, layoutControl.getWidth(), wi + ini); |
|
339 |
g.drawLine(w, ini, layoutControl.getWidth(), ini); |
|
340 |
g.drawLine(ini, w, ini, layoutControl.getHeight()); |
|
341 |
g.drawLine(wi + ini, w, wi + ini, layoutControl.getHeight()); |
|
342 |
|
|
343 |
drawLineY(g, 5, 12, 22, rLayout.getY(), 0); |
|
344 |
drawLineX(g, 5, 12, 22, rLayout.getX(), 0); |
|
345 |
|
|
346 |
if (FLayoutUtilities.fromSheetDistance(1, at) > 15) { |
|
347 |
drawLineY(g, 1, 12, 22, rLayout.getY(), 0); |
|
348 |
drawLineX(g, 1, 12, 22, rLayout.getX(), 0); |
|
349 |
|
|
350 |
if (FLayoutUtilities.fromSheetDistance(1, at) > 25) { |
|
351 |
drawLineY(g, 1, 18, 22, rLayout.getY(), 0.5); |
|
352 |
drawLineY(g, 0.1, 21, 22, rLayout.getY(), 0); |
|
353 |
drawLineX(g, 1, 18, 22, rLayout.getX(), 0.5); |
|
354 |
drawLineX(g, 0.1, 21, 22, rLayout.getX(), 0); |
|
355 |
} |
|
356 |
} |
|
357 |
} |
|
358 |
} |
|
359 |
|
|
360 |
/** |
|
361 |
* Dibuja sobre el graphics2d las l?neas verticales que representan a las |
|
362 |
* unidades de medida. |
|
363 |
* |
|
364 |
* @param g |
|
365 |
* Graphics2d sobre el que se dibuja. |
|
366 |
* @param dist |
|
367 |
* distancia en cent?metros de una l?nea a otra. |
|
368 |
* @param init |
|
369 |
* inicio de la l?nea. |
|
370 |
* @param end |
|
371 |
* fin de la l?nea. |
|
372 |
* @param y |
|
373 |
* rect?ngulo, dentro del cual se dibujan las l?neas. |
|
374 |
* @param desp |
|
375 |
* Desplazamiento. |
|
376 |
*/ |
|
377 |
private void drawLineY(Graphics2D g, double dist, int init, int end, |
|
378 |
double y, double desp) { |
|
379 |
initialize(); |
|
380 |
AffineTransform at = layoutContext.getAT(); |
|
381 |
|
|
382 |
double distY = FLayoutUtilities.fromSheetDistance(dist, at); |
|
383 |
double rota = Math.toRadians(90); |
|
384 |
|
|
385 |
if (distY > 4) { |
|
386 |
double despY = FLayoutUtilities.fromSheetDistance(desp, at); |
|
387 |
|
|
388 |
double posUnitY = y + despY; |
|
389 |
double posUnitYNeg = posUnitY; |
|
390 |
int num = 0; |
|
391 |
double iniY = 40; |
|
392 |
Point2D.Double pfin = |
|
393 |
FLayoutUtilities.fromSheetPoint(new Point2D.Double( |
|
394 |
layoutControl.getWidth(), layoutControl.getHeight()), at); |
|
395 |
|
|
396 |
while (posUnitY < (pfin.y - 5)) { |
|
397 |
posUnitYNeg -= distY; |
|
398 |
|
|
399 |
if (distY > 16) { |
|
400 |
if (init == 12) { |
|
401 |
if (posUnitY > iniY) { |
|
402 |
g.rotate(-rota, 20, posUnitY - 12); |
|
403 |
g.drawString(String.valueOf(num), 10, |
|
404 |
(int) posUnitY - 12); |
|
405 |
g.rotate(rota, 20, posUnitY - 12); |
|
406 |
} |
|
407 |
|
|
408 |
if (dist == 5) { |
|
409 |
num = num + 5; |
|
410 |
} else { |
|
411 |
num++; |
|
412 |
} |
|
413 |
|
|
414 |
if (posUnitYNeg > iniY) { |
|
415 |
g.rotate(-rota, 20, posUnitYNeg - 12); |
|
416 |
g.drawString(String.valueOf(-num), 10, |
|
417 |
(int) posUnitYNeg - 12); |
|
418 |
g.rotate(rota, 20, posUnitYNeg - 12); |
|
419 |
} |
|
420 |
} |
|
421 |
} |
|
422 |
|
|
423 |
if (posUnitY > iniY) { |
|
424 |
g.drawLine(2 + init, (int) posUnitY, 2 + end, |
|
425 |
(int) posUnitY); |
|
426 |
} |
|
427 |
|
|
428 |
if (posUnitYNeg > iniY) { |
|
429 |
g.drawLine(2 + init, (int) posUnitYNeg, 2 + end, |
|
430 |
(int) posUnitYNeg); |
|
431 |
} |
|
432 |
|
|
433 |
posUnitY += distY; |
|
434 |
} |
|
435 |
} |
|
436 |
} |
|
437 |
|
|
438 |
/** |
|
439 |
* Dibuja sobre el graphics2d las l?neas horizontales que representan a las |
|
440 |
* unidades de medida. |
|
441 |
* |
|
442 |
* @param g |
|
443 |
* Graphics2d sobre el que se dibuja. |
|
444 |
* @param dist |
|
445 |
* distancia en cent?metros de una l?nea a otra. |
|
446 |
* @param init |
|
447 |
* inicio de la l?nea. |
|
448 |
* @param end |
|
449 |
* fin de la l?nea. |
|
450 |
* @param x |
|
451 |
* rect?ngulo, dentro del cual se dibujan las l?neas. |
|
452 |
* @param desp |
|
453 |
* Desplazamiento. |
|
454 |
*/ |
|
455 |
private void drawLineX(Graphics2D g, double dist, int init, int end, |
|
456 |
double x, double desp) { |
|
457 |
initialize(); |
|
458 |
AffineTransform at = layoutContext.getAT(); |
|
459 |
|
|
460 |
double distX = FLayoutUtilities.fromSheetDistance(dist, at); |
|
461 |
|
|
462 |
if (distX > 4) { |
|
463 |
double despX = FLayoutUtilities.fromSheetDistance(desp, at); |
|
464 |
double posUnitX = x + despX; |
|
465 |
double posUnitXNeg = posUnitX; |
|
466 |
int num = 0; |
|
467 |
double iniX = 40; |
|
468 |
Point2D.Double pfin = |
|
469 |
FLayoutUtilities.fromSheetPoint(new Point2D.Double( |
|
470 |
layoutControl.getWidth(), layoutControl.getHeight()), at); |
|
471 |
|
|
472 |
while (posUnitX < (pfin.x - 5)) { |
|
473 |
posUnitXNeg -= distX; |
|
474 |
|
|
475 |
if (init == 12) { |
|
476 |
if (distX > 16) { |
|
477 |
if (posUnitX > iniX) { |
|
478 |
g.drawString(String.valueOf(num), |
|
479 |
(int) posUnitX + 3, 20); |
|
480 |
} |
|
481 |
|
|
482 |
if (dist == 5) { |
|
483 |
num = num + 5; |
|
484 |
} else { |
|
485 |
num++; |
|
486 |
} |
|
487 |
|
|
488 |
if (posUnitXNeg > iniX) { |
|
489 |
g.drawString(String.valueOf(-num), |
|
490 |
(int) posUnitXNeg + 3, 20); |
|
491 |
} |
|
492 |
} |
|
493 |
} |
|
494 |
|
|
495 |
if (posUnitX > iniX) { |
|
496 |
g.drawLine((int) posUnitX, 2 + init, (int) posUnitX, |
|
497 |
2 + end); |
|
498 |
} |
|
499 |
|
|
500 |
if (posUnitXNeg > iniX) { |
|
501 |
g.drawLine((int) posUnitXNeg, 2 + init, (int) posUnitXNeg, |
|
502 |
2 + end); |
|
503 |
} |
|
504 |
|
|
505 |
posUnitX += distX; |
|
506 |
} |
|
507 |
} |
|
508 |
} |
|
509 |
|
|
510 |
/** |
|
511 |
* Dibuja los handlers sobre los fframes que esten seleccionados. |
|
512 |
* |
|
513 |
* @param g |
|
514 |
* Graphics sobre el que se dibuja. |
|
515 |
* @param color |
|
516 |
* Color de los Handlers. |
|
517 |
*/ |
|
518 |
public void drawHandlers(Graphics2D g, Color color) { |
|
519 |
initialize(); |
|
520 |
|
|
521 |
g.setColor(color); |
|
522 |
IFFrame[] fframes = layoutContext.getFFrames(); |
|
523 |
for (int i = 0; i < fframes.length; i++) { |
|
524 |
IFFrame fframe = fframes[i]; |
|
525 |
|
|
526 |
if (fframe.getSelected() != IFFrame.NOSELECT) { |
|
527 |
fframe.drawHandlers(g); |
|
528 |
} |
|
529 |
} |
|
530 |
} |
|
531 |
|
|
532 |
/** |
|
533 |
* A partir de un fichero que se pasa como par?metro se crea un ps con el |
|
534 |
* contenido del Layout. |
|
535 |
* |
|
536 |
* @param ps |
|
537 |
*/ |
|
538 |
public void toPS(File ps) { |
|
539 |
initialize(); |
|
540 |
Attributes attributes = layoutContext.getAttributes(); |
|
541 |
|
|
542 |
try { |
|
543 |
// Prepare the output file to receive the postscript |
|
544 |
OutputStream fos = |
|
545 |
new BufferedOutputStream(new FileOutputStream(ps)); |
|
546 |
|
|
547 |
// Find a factory that can do the conversion |
|
548 |
// DocFlavor flavor = DocFlavor.INPUT_STREAM.GIF; |
|
549 |
DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE; |
|
550 |
StreamPrintServiceFactory[] factories = |
|
551 |
StreamPrintServiceFactory.lookupStreamPrintServiceFactories( |
|
552 |
flavor, "application/postscript"); |
|
553 |
|
|
554 |
if (factories.length > 0) { |
|
555 |
StreamPrintService service = factories[0].getPrintService(fos); |
|
556 |
|
|
557 |
// Create the print job |
|
558 |
DocPrintJob job = service.createPrintJob(); |
|
559 |
Doc doc = new SimpleDoc(this, flavor, null); |
|
560 |
// Doc doc = new SimpleDoc(is, flavor, null); |
|
561 |
// Monitor print job events; for the implementation of |
|
562 |
// PrintJobWatcher, |
|
563 |
// see e702 Determining When a Print Job Has Finished |
|
564 |
// PrintJobWatcher pjDone = new PrintJobWatcher(job); |
|
565 |
// Actualizar attributes |
|
566 |
PrintRequestAttributeSet att = |
|
567 |
attributes.toPrintRequestAttributeSet(); |
|
568 |
// Print it |
|
569 |
job.print(doc, att); |
|
570 |
|
|
571 |
// Wait for the print job to be done |
|
572 |
// pjDone.waitForDone(); |
|
573 |
// It is now safe to close the streams |
|
574 |
} |
|
575 |
|
|
576 |
// is.close(); |
|
577 |
fos.close(); |
|
578 |
} catch (PrintException e) { |
|
579 |
LOG.error("Error printing the map", e); |
|
580 |
} catch (IOException e) { |
|
581 |
LOG.error("Error printing the map", e); |
|
582 |
} |
|
583 |
/* |
|
584 |
* PrintService defaultPrintService = |
|
585 |
* PrintServiceLookup.lookupDefaultPrintService(); |
|
586 |
* DocPrintJob printerJob = defaultPrintService.createPrintJob(); |
|
587 |
* |
|
588 |
* try { |
|
589 |
* DocFlavor flavor=DocFlavor.URL.POSTSCRIPT; |
|
590 |
* if (!defaultPrintService.isDocFlavorSupported(flavor)) { |
|
591 |
* System.err.println( |
|
592 |
* "The printer does not support the appropriate DocFlavor"); |
|
593 |
* }else { |
|
594 |
* |
|
595 |
* SimpleDoc simpleDoc; |
|
596 |
* simpleDoc = new SimpleDoc(ps.toURL(),flavor, null); |
|
597 |
* printerJob.print(simpleDoc, null); |
|
598 |
* } |
|
599 |
* } catch (MalformedURLException e) { |
|
600 |
* // TODO Auto-generated catch block |
|
601 |
* e.printStackTrace(); |
|
602 |
* } catch (PrintException e) { |
|
603 |
* // TODO Auto-generated catch block |
|
604 |
* e.printStackTrace(); |
|
605 |
* } |
|
606 |
*/ |
|
607 |
layoutControl.fullRect(); |
|
608 |
} |
|
609 |
|
|
610 |
/** |
|
611 |
* A partir de un fichero que se pasa como par?metro se crea un pdf con el |
|
612 |
* contenido del Layout. |
|
613 |
* |
|
614 |
* @param pdf |
|
615 |
*/ |
|
616 |
public void toPDF(File pdf) { |
|
617 |
Attributes attributes = layoutContext.getAttributes(); |
|
618 |
|
|
619 |
double w = ((attributes.getPaperSize().getWidth() * Attributes.DPISCREEN) / Attributes.PULGADA); |
|
620 |
double h = ((attributes.getPaperSize().getHeight() * Attributes.DPISCREEN) / Attributes.PULGADA); |
|
621 |
Rectangle pageSize = new com.lowagie.text.Rectangle((float) w, (float) h); |
|
622 |
Document document = new Document(pageSize); |
|
623 |
|
|
624 |
try { |
|
625 |
FileOutputStream fos = new FileOutputStream(pdf); |
|
626 |
PdfWriter writer = PdfWriter.getInstance(document, fos); |
|
627 |
document.open(); |
|
628 |
|
|
629 |
PdfContentByte cb = writer.getDirectContent(); |
|
630 |
Graphics2D g2 = cb.createGraphicsShapes((float) w, (float) h); |
|
631 |
|
|
632 |
try { |
|
633 |
print(g2, new PageFormat(), 0); |
|
634 |
} catch (PrinterException e) { |
|
635 |
LOG.error("Error printing the map", e); |
|
636 |
} |
|
637 |
g2.dispose(); |
|
638 |
|
|
639 |
} catch (DocumentException de) { |
|
640 |
LOG.error("Error printing the map", de); |
|
641 |
} catch (IOException ioe) { |
|
642 |
JOptionPane.showMessageDialog( |
|
643 |
(Component) PluginServices.getMainFrame(), ioe.getMessage()); |
|
644 |
} |
|
645 |
|
|
646 |
document.close(); |
|
647 |
|
|
648 |
layoutControl.fullRect(); |
|
649 |
} |
|
650 |
|
|
651 |
public int print(Graphics g, PageFormat format, int pi) |
|
652 |
throws PrinterException { |
|
653 |
initialize(); |
|
654 |
if (pi >= 1) { |
|
655 |
return Printable.NO_SUCH_PAGE; |
|
656 |
} |
|
657 |
|
|
658 |
Graphics2D g2d = (Graphics2D) g; |
|
659 |
|
|
660 |
AffineTransform at = g2d.getTransform(); |
|
661 |
g2d.translate(0, 0); |
|
662 |
layoutPanel.obtainRect(true); |
|
663 |
|
|
664 |
g2d.scale((double) 72 / (double) (Attributes.DPI), (double) 72 |
|
665 |
/ (double) (Attributes.DPI)); |
|
666 |
|
|
667 |
if (layoutContext.getAttributes().isMargin()) { |
|
668 |
g2d.setClip( |
|
669 |
(int) (layoutControl.getRect().getMinX() + FLayoutUtilities.fromSheetDistance( |
|
670 |
layoutContext.getAttributes().getAreaInsets()[2], layoutControl.getAT())), |
|
671 |
(int) (layoutPanel.getLayoutControl().getRect().getMinY() + FLayoutUtilities.fromSheetDistance( |
|
672 |
layoutContext.getAttributes().getAreaInsets()[0], layoutControl.getAT())), |
|
673 |
(int) (layoutControl.getRect().getWidth() - FLayoutUtilities.fromSheetDistance( |
|
674 |
layoutContext.getAttributes().getAreaInsets()[2] + layoutContext.getAttributes().getAreaInsets()[3], layoutControl.getAT())), |
|
675 |
(int) (layoutPanel.getLayoutControl().getRect().getHeight() - FLayoutUtilities.fromSheetDistance( |
|
676 |
layoutContext.getAttributes().getAreaInsets()[0] + layoutContext.getAttributes().getAreaInsets()[1], layoutControl.getAT()))); |
|
677 |
} |
|
678 |
drawShapes(g2d); |
|
679 |
g2d.setTransform(at); |
|
680 |
return Printable.PAGE_EXISTS; |
|
681 |
} |
|
682 |
|
|
683 |
/** |
|
684 |
* Se dibuja sobre el graphics el Layout. |
|
685 |
* |
|
686 |
* @param g2 |
|
687 |
* graphics sobre el que se dibuja. |
|
688 |
*/ |
|
689 |
public void drawShapes(Graphics2D g2) { |
|
690 |
initialize(); |
|
691 |
layoutPanel.setCursor(Cursor.getDefaultCursor()); |
|
692 |
if (!initializeAffineTransform()) { |
|
693 |
return; |
|
694 |
} |
|
695 |
|
|
696 |
IFFrame[] fframes = layoutContext.getFFrames(); |
|
697 |
for (int i = 0; i < fframes.length; i++) { |
|
698 |
fframes[i].print(g2, layoutControl.getAT(), null, layoutContext |
|
699 |
.getAttributes().toPrintAttributes()); |
|
700 |
} |
|
701 |
} |
|
702 |
|
|
703 |
public void addObserver(Observer o) { |
|
704 |
observers.addObserver(o); |
|
705 |
} |
|
706 |
|
|
707 |
public void deleteObserver(Observer o) { |
|
708 |
observers.deleteObserver(o); |
|
709 |
} |
|
710 |
|
|
711 |
public void deleteObservers() { |
|
712 |
observers.deleteObservers(); |
|
713 |
} |
|
714 |
} |
tags/org.gvsig.app.document.layout2.app-2.0.176/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/TocModelChangedImpl.java | ||
---|---|---|
1 |
package org.gvsig.app.project.documents.layout; |
|
2 |
|
|
3 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
4 |
|
|
5 |
public class TocModelChangedImpl implements TocModelChangedNotification { |
|
6 |
private MapContext mapContext = null; |
|
7 |
private Type type = null; |
|
8 |
|
|
9 |
public TocModelChangedImpl(Type type, MapContext model) { |
|
10 |
this.type = type; |
|
11 |
this.mapContext = model; |
|
12 |
} |
|
13 |
|
|
14 |
public MapContext getModel() { |
|
15 |
return mapContext; |
|
16 |
} |
|
17 |
|
|
18 |
public Type getType() { |
|
19 |
return type; |
|
20 |
} |
|
21 |
|
|
22 |
} |
tags/org.gvsig.app.document.layout2.app-2.0.176/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/LayoutEvents.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.event.ActionEvent; |
|
25 |
import java.awt.event.ActionListener; |
|
26 |
import java.awt.event.ComponentEvent; |
|
27 |
import java.awt.event.ComponentListener; |
|
28 |
import java.awt.event.MouseEvent; |
|
29 |
import java.awt.event.MouseListener; |
|
30 |
import java.awt.event.MouseMotionListener; |
|
31 |
|
|
32 |
import org.gvsig.app.project.documents.layout.gui.FPopupMenu; |
|
33 |
import org.gvsig.app.project.documents.layout.gui.LayoutPanel; |
|
34 |
import org.gvsig.fmap.mapcontrol.tools.BehaviorException; |
|
35 |
import org.gvsig.utils.exceptionHandling.ExceptionHandlingSupport; |
|
36 |
import org.gvsig.utils.exceptionHandling.ExceptionListener; |
|
37 |
|
|
38 |
/** |
|
39 |
* Eventos que se realizan sobre el Layout. |
|
40 |
* |
|
41 |
* @author Vicente Caballero Navarro |
|
42 |
*/ |
|
43 |
public class LayoutEvents implements ActionListener, ComponentListener, |
|
44 |
MouseMotionListener, MouseListener { |
|
45 |
|
|
46 |
private LayoutPanel layout = null; |
|
47 |
private ExceptionHandlingSupport exceptionHandlingSupport = |
|
48 |
new ExceptionHandlingSupport(); |
|
49 |
|
|
50 |
/** |
|
51 |
* Crea un nuevo EventsHandler. |
|
52 |
* |
|
53 |
* @param l |
|
54 |
* Referencia al Layout. |
|
55 |
*/ |
|
56 |
public LayoutEvents(LayoutPanel l) { |
|
57 |
layout = l; |
|
58 |
} |
|
59 |
|
|
60 |
/** |
|
61 |
* @see java.awt.event.ComponentListener#componentHidden(java.awt.event.ComponentEvent) |
|
62 |
*/ |
|
63 |
public void componentHidden(ComponentEvent arg0) { |
|
64 |
} |
|
65 |
|
|
66 |
/** |
|
67 |
* @see java.awt.event.ComponentListener#componentMoved(java.awt.event.ComponentEvent) |
|
68 |
*/ |
|
69 |
public void componentMoved(ComponentEvent arg0) { |
|
70 |
} |
|
71 |
|
|
72 |
/** |
|
73 |
* @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent) |
|
74 |
*/ |
|
75 |
public void componentResized(ComponentEvent arg0) { |
|
76 |
// layout.getLayoutControl().fullRect(); |
|
77 |
layout.getLayoutControl().refresh(); |
|
78 |
} |
|
79 |
|
|
80 |
/** |
|
81 |
* @see java.awt.event.ComponentListener#componentShown(java.awt.event.ComponentEvent) |
|
82 |
*/ |
|
83 |
public void componentShown(ComponentEvent arg0) { |
|
84 |
} |
|
85 |
|
|
86 |
/** |
|
87 |
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) |
|
88 |
*/ |
|
89 |
public void actionPerformed(ActionEvent arg0) { |
|
90 |
layout.repaint(); |
|
91 |
} |
|
92 |
|
|
93 |
/** |
|
94 |
* @see java.awt.event.MouseMotionListener#mouseDragged(java.awt.event.MouseEvent) |
|
95 |
*/ |
|
96 |
public void mouseDragged(MouseEvent e) { |
|
97 |
if (e.getButton() != MouseEvent.BUTTON3) { |
|
98 |
layout.getLayoutControl().setLastPoint(); |
|
99 |
layout.repaint(); |
|
100 |
} |
|
101 |
try { |
|
102 |
layout.getLayoutControl().getCurrentLayoutTool().mouseDragged(e); |
|
103 |
} catch (BehaviorException t) { |
|
104 |
throwException(t); |
|
105 |
} |
|
106 |
layout.getLayoutControl().setPosition(e.getPoint()); |
|
107 |
} |
|
108 |
|
|
109 |
/** |
|
110 |
* @see java.awt.event.MouseMotionListener#mouseMoved(java.awt.event.MouseEvent) |
|
111 |
*/ |
|
112 |
public void mouseMoved(MouseEvent e) { |
|
113 |
layout.getLayoutControl().setPosition(e.getPoint()); |
|
114 |
try { |
|
115 |
layout.getLayoutControl().getCurrentLayoutTool().mouseMoved(e); |
|
116 |
} catch (BehaviorException t) { |
|
117 |
throwException(t); |
|
118 |
} |
|
119 |
layout.repaint(); |
|
120 |
} |
|
121 |
|
|
122 |
/** |
|
123 |
* @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent) |
|
124 |
*/ |
|
125 |
public void mouseClicked(MouseEvent e) { |
|
126 |
try { |
|
127 |
layout.getLayoutControl().getComponent().requestFocusInWindow(); |
|
128 |
layout.getLayoutControl().getCurrentLayoutTool().mouseClicked(e); |
|
129 |
} catch (BehaviorException t) { |
|
130 |
throwException(t); |
|
131 |
} |
|
132 |
} |
|
133 |
|
|
134 |
/** |
|
135 |
* A?ade un listener de tipo ExceptionListener. |
|
136 |
* |
|
137 |
* @param o |
|
138 |
* ExceptionListener. |
|
139 |
*/ |
|
140 |
public void addExceptionListener(ExceptionListener o) { |
|
141 |
exceptionHandlingSupport.addExceptionListener(o); |
|
142 |
} |
|
143 |
|
|
144 |
/** |
|
145 |
* Borra la ExceptioListener que se pasa como par?metro. |
|
146 |
* |
|
147 |
* @param o |
|
148 |
* ExceptionListener. |
|
149 |
* |
|
150 |
* @return True si se borra correctamente. |
|
151 |
*/ |
|
152 |
public boolean removeExceptionListener(ExceptionListener o) { |
|
153 |
return exceptionHandlingSupport.removeExceptionListener(o); |
|
154 |
} |
|
155 |
|
|
156 |
/** |
|
157 |
* Lanza una Excepci?n. |
|
158 |
* |
|
159 |
* @param t |
|
160 |
* Excepci?n. |
|
161 |
*/ |
|
162 |
protected void throwException(Throwable t) { |
|
163 |
exceptionHandlingSupport.throwException(t); |
|
164 |
} |
|
165 |
|
|
166 |
/** |
|
167 |
* @see java.awt.event.MouseListener#mouseEntered(java.awt.event.MouseEvent) |
|
168 |
*/ |
|
169 |
public void mouseEntered(MouseEvent e) { |
|
170 |
layout.getLayoutControl().clearMouseImage(); |
|
171 |
try { |
|
172 |
layout.getLayoutControl().getCurrentLayoutTool().mouseEntered(e); |
|
173 |
} catch (BehaviorException t) { |
|
174 |
throwException(t); |
|
175 |
} |
|
176 |
} |
|
177 |
|
|
178 |
/** |
|
179 |
* @see java.awt.event.MouseListener#mouseExited(java.awt.event.MouseEvent) |
|
180 |
*/ |
|
181 |
public void mouseExited(MouseEvent e) { |
|
182 |
try { |
|
183 |
layout.getLayoutControl().getCurrentLayoutTool().mouseExited(e); |
|
184 |
} catch (BehaviorException t) { |
|
185 |
throwException(t); |
|
186 |
} |
|
187 |
} |
|
188 |
|
|
189 |
/** |
|
190 |
* @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent) |
|
191 |
*/ |
|
192 |
public void mousePressed(MouseEvent e) { |
|
193 |
if (e.getButton() == MouseEvent.BUTTON1) { |
|
194 |
layout.getLayoutControl().setPointAnt(); |
|
195 |
layout.getLayoutControl().setFirstPoint(); |
|
196 |
try { |
|
197 |
layout.getLayoutControl().getCurrentLayoutTool() |
|
198 |
.mousePressed(e); |
|
199 |
} catch (BehaviorException t) { |
|
200 |
throwException(t); |
|
201 |
} |
|
202 |
} else |
|
203 |
if (e.getButton() == MouseEvent.BUTTON3) { |
|
204 |
FPopupMenu popmenu = new FPopupMenu(layout); |
|
205 |
layout.add(popmenu); |
|
206 |
popmenu.show(e.getComponent(), e.getX(), e.getY()); |
|
207 |
} |
|
208 |
} |
|
209 |
|
|
210 |
/** |
|
211 |
* @see java.awt.event.MouseListener#mouseReleassed(java.awt.event.MouseEvent) |
|
212 |
*/ |
|
213 |
public void mouseReleased(MouseEvent e) { |
|
214 |
if (e.getButton() != MouseEvent.BUTTON3) { |
|
215 |
layout.getLayoutControl().setLastPoint(); |
|
216 |
} |
|
217 |
|
|
218 |
if (e.getButton() == MouseEvent.BUTTON1) { |
|
219 |
try { |
|
220 |
layout.getLayoutControl().getCurrentLayoutTool() |
|
221 |
.mouseReleased(e); |
|
222 |
} catch (BehaviorException t) { |
|
223 |
throwException(t); |
|
224 |
} |
|
225 |
layout.getLayoutControl().setCancelDrawing(false); |
|
226 |
} else |
|
227 |
if (e.getButton() == MouseEvent.BUTTON3) { |
|
228 |
} |
|
229 |
|
|
230 |
} |
|
231 |
} |
tags/org.gvsig.app.document.layout2.app-2.0.176/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/fframes/IFFrameEditableVertex.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.fframes; |
|
23 |
|
|
24 |
import java.awt.Graphics2D; |
|
25 |
import java.awt.geom.AffineTransform; |
|
26 |
import java.awt.geom.Point2D; |
|
27 |
|
|
28 |
import org.gvsig.app.project.documents.layout.geometryadapters.GeometryAdapter; |
|
29 |
|
|
30 |
public interface IFFrameEditableVertex { |
|
31 |
|
|
32 |
void startEditing(); |
|
33 |
|
|
34 |
void stopEditing(); |
|
35 |
|
|
36 |
boolean isEditing(); |
|
37 |
|
|
38 |
void pointPressed(Point2D point); |
|
39 |
|
|
40 |
void pointReleased(Point2D point, GeometryAdapter geom); |
|
41 |
|
|
42 |
void pointDragged(Point2D point); |
|
43 |
|
|
44 |
void paint(Graphics2D g, AffineTransform at); |
|
45 |
|
|
46 |
GeometryAdapter getGeometry(); |
|
47 |
} |
tags/org.gvsig.app.document.layout2.app-2.0.176/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/fframes/FFrameBasic.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.fframes; |
|
23 |
|
|
24 |
import java.awt.Color; |
|
25 |
import java.awt.Graphics2D; |
|
26 |
import java.awt.event.MouseEvent; |
|
27 |
import java.awt.geom.AffineTransform; |
|
28 |
import java.awt.geom.Point2D; |
|
29 |
import java.awt.geom.Point2D.Double; |
|
30 |
import java.awt.geom.Rectangle2D; |
|
31 |
import java.awt.image.BufferedImage; |
|
32 |
|
|
33 |
import org.gvsig.andami.PluginServices; |
|
34 |
import org.gvsig.app.project.documents.layout.geometryadapters.PolygonAdapter; |
|
35 |
import org.gvsig.compat.print.PrintAttributes; |
|
36 |
import org.gvsig.fmap.geom.Geometry; |
|
37 |
import org.gvsig.fmap.mapcontext.MapContextLocator; |
|
38 |
import org.gvsig.fmap.mapcontext.MapContextManager; |
|
39 |
import org.gvsig.symbology.SymbologyLocator; |
|
40 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.IFillSymbol; |
|
41 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.line.ISimpleLineSymbol; |
|
42 |
import org.gvsig.tools.ToolsLocator; |
|
43 |
import org.gvsig.tools.dynobject.DynStruct; |
|
44 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
45 |
import org.gvsig.tools.persistence.PersistentState; |
|
46 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
|
47 |
|
|
48 |
/** |
|
49 |
* FFrame b?sica que contiene una FFrame de cualquier tipo. |
|
50 |
* |
|
51 |
* @author Vicente Caballero Navarro |
|
52 |
*/ |
|
53 |
public class FFrameBasic extends FFrame { |
|
54 |
|
|
55 |
public static final String PERSISTENCE_DEFINITION_NAME = "FFrameBasic"; |
|
56 |
|
|
57 |
private static final String FFRAMEGRAPHICS_FIELD = "fframeGraphics"; |
|
58 |
private static final String FFRAME_FIELD = "fframe"; |
|
59 |
|
|
60 |
private FFrameGraphics fframeGraphics; |
|
61 |
private IFFrame fframe; |
|
62 |
|
|
63 |
private MapContextManager mapContextManager = MapContextLocator |
|
64 |
.getMapContextManager(); |
|
65 |
|
|
66 |
public void setRectangle(Rectangle2D r) { |
|
67 |
FFrameGraphics graphics = |
|
68 |
(FFrameGraphics) layoutManager |
|
69 |
.createFrame(FFrameGraphics.PERSISTENCE_DEFINITION_NAME); |
|
70 |
PolygonAdapter pa = new PolygonAdapter(); |
|
71 |
pa.addPoint(new Point2D.Double(r.getX(), r.getY())); |
|
72 |
pa.addPoint(new Point2D.Double(r.getMaxX(), r.getY())); |
|
73 |
pa.addPoint(new Point2D.Double(r.getMaxX(), r.getMaxY())); |
|
74 |
pa.addPoint(new Point2D.Double(r.getX(), r.getMaxY())); |
|
75 |
pa.addPoint(new Point2D.Double(r.getX(), r.getY())); |
|
76 |
pa.end(); |
|
77 |
graphics.setGeometryAdapter(pa); |
|
78 |
graphics.setBoundBox(r); |
|
79 |
|
|
80 |
IFillSymbol symbol = |
|
81 |
(IFillSymbol) mapContextManager.getSymbolManager().createSymbol( |
|
82 |
IFillSymbol.SYMBOL_NAME); |
|
83 |
symbol.setFillColor(new Color(255, 255, 255, 0)); |
|
84 |
ISimpleLineSymbol blackOutline = |
|
85 |
SymbologyLocator.getSymbologyManager().createSimpleLineSymbol(); |
|
86 |
blackOutline.setLineColor(Color.BLACK); |
|
87 |
symbol.setOutline(blackOutline); |
|
88 |
graphics.setSymbol(symbol); |
|
89 |
graphics.setType(Geometry.TYPES.CURVE); |
|
90 |
setFframeGraphics(graphics); |
|
91 |
} |
|
92 |
|
|
93 |
public FFrameBasic() { |
|
94 |
|
|
95 |
} |
|
96 |
|
|
97 |
/** |
|
98 |
* M?todo que dibuja sobre el graphics que se le pasa como par?metro, seg?n |
|
99 |
* la transformada afin que se debe de aplicar y el rect?ngulo que se debe |
|
100 |
* de dibujar. |
|
101 |
* |
|
102 |
* @param g |
|
103 |
* Graphics |
|
104 |
* @param at |
|
105 |
* Transformada afin. |
|
106 |
* @param rv |
|
107 |
* rect?ngulo sobre el que hacer un clip. |
|
108 |
* @param imgBase |
|
109 |
* Imagen para acelerar el dibujado. |
|
110 |
*/ |
|
111 |
public void draw(Graphics2D g, AffineTransform at, Rectangle2D rv, |
|
112 |
BufferedImage imgBase) { |
|
113 |
fframeGraphics.draw(g, at, rv, imgBase); |
|
114 |
if (fframe != null) { |
|
115 |
fframe.draw(g, at, rv, imgBase); |
|
116 |
} |
|
117 |
} |
|
118 |
|
|
119 |
/** |
|
120 |
* @see org.gvsig.app.project.documents.layout.fframes.IFFrame#getNameFFrame() |
|
121 |
*/ |
|
122 |
public String getNameFFrame() { |
|
123 |
return PluginServices.getText(this, "base") + num; |
|
124 |
} |
|
125 |
|
|
126 |
/** |
|
127 |
* @see org.gvsig.app.project.documents.layout.fframes.IFFrame#print(java.awt.Graphics2D, |
|
128 |
* java.awt.geom.AffineTransform) |
|
129 |
*/ |
Also available in: Unified diff