Revision 1410

View differences:

tags/org.gvsig.app.document.layout2.app-2.0.245/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.245</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.381</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.245</connection>
21
        <developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-app-document-layout/tags/org.gvsig.app.document.layout2.app-2.0.245</developerConnection>
22
        <url>https://devel.gvsig.org/redmine/projects/gvsig-app-document-layout/repository/show/tags/org.gvsig.app.document.layout2.app-2.0.245</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.245</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>
tags/org.gvsig.app.document.layout2.app-2.0.245/org.gvsig.app.document.layout2.app.mainplugin/buildNumber.properties
1
#Mon Jul 18 19:37:44 CEST 2022
2
buildNumber=265
tags/org.gvsig.app.document.layout2.app-2.0.245/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.245/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.245/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/LayoutManager.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.DocumentManager;
27
import org.gvsig.app.project.documents.layout.fframes.FrameFactory;
28
import org.gvsig.app.project.documents.layout.fframes.IFFrame;
29
import org.gvsig.app.project.documents.layout.fframes.gui.dialogs.IFFrameDialog;
30
import org.gvsig.app.project.documents.layout.gui.LayoutPanel;
31
import org.gvsig.app.project.documents.view.IContextMenuAction;
32

  
33
/**
34
 * @author gvSIG Team
35
 * @version $Id: LayoutManager.java 34861 2011-03-31 11:31:50Z nfrancisco $
36
 * 
37
 */
38
public interface LayoutManager extends DocumentManager {
39
    public static String TYPENAME = "project.document.layout";
40
    public static final String TEMPLATE_FILE_POINTEXT = ".gvslt";
41

  
42
    public IFFrame createFrame(String frameName);
43

  
44
    public IFFrameDialog createFFrameDialog(IFFrame fframe,
45
        LayoutPanel layoutPanel, AffineTransform affineTransform);
46

  
47
    public IFFrameDialog createFFrameDialog(IFFrame fframe,
48
        LayoutPanel layoutPanel);
49
    
50
    public void registerFFrameDialog(String name, Class clazz);
51
    
52
    /**
53
     * Registers in the points of extension the Factory with alias.
54
     * 
55
     * @param frameFactory
56
     *            FrameFactory to register.
57
     * @param alias
58
     *            Alias.
59
     */
60
    public void registerFrameFactory(FrameFactory frameFactory, String alias);
61
    
62
    /**
63
     * Registers in the points of extension the Factory
64
     * 
65
     * @param frameFactory
66
     *            FrameFactory to register.
67
     */
68
    public void registerFrameFactory(FrameFactory frameFactory);
69
    
70
    public void registerLayoutMenuAction(String name, Class<? extends IContextMenuAction> clazz);
71
    
72
    public IContextMenuAction[] createLayoutMenuActions(LayoutPanel layoutPanel);
73
}
tags/org.gvsig.app.document.layout2.app-2.0.245/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/CustomizableObserverHelper.java
1
package org.gvsig.app.project.documents.layout;
2

  
3
import java.util.ArrayList;
4
import java.util.List;
5

  
6
import org.gvsig.tools.observer.Observable;
7

  
8
/**
9
 * The goal of this class is to be extended internally by a 
10
 * class wishing to manage specific listeners.
11
 * 
12
 * @author Cesar Martinez
13
 */
14
public abstract class CustomizableObserverHelper {
15

  
16
	private List listeners = new ArrayList();
17
	
18
	public synchronized void addObserver(Object o) {
19
		if( this.listeners.contains(o) ) {
20
			return;
21
		}
22
		this.listeners.add(o);
23
	}
24

  
25
	public synchronized void deleteObserver(Object o) {
26
		this.listeners.remove(o);
27
	}
28

  
29
	public synchronized void deleteObservers() {
30
		this.listeners = new ArrayList();
31
	}
32

  
33
	public synchronized void notifyObservers(Object observable, Object data) {
34
		for(int i =0; i<this.listeners.size(); i++ ) {
35
			Object o = (Object) this.listeners.get(i);
36
			doNotify(o, data);
37
		}
38

  
39
	}
40
	
41
	protected abstract void doNotify(Object listener, Object data);
42
}
43

  
tags/org.gvsig.app.document.layout2.app-2.0.245/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/Size.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 org.gvsig.tools.ToolsLocator;
25
import org.gvsig.tools.dynobject.DynStruct;
26
import org.gvsig.tools.persistence.PersistenceManager;
27
import org.gvsig.tools.persistence.Persistent;
28
import org.gvsig.tools.persistence.PersistentState;
29
import org.gvsig.tools.persistence.exception.PersistenceException;
30

  
31
/**
32
 * Clase que almacena la altura y anchura de un folio.
33
 * 
34
 * @author Vicente Caballero Navarro
35
 */
36
public class Size implements Persistent {
37

  
38
    public static final String PERSISTENCE_DEFINITION_NAME = "Size";
39
    private static final String HEIGHT_FIELD = "height";
40
    private static final String WIDTH_FIELD = "width";
41

  
42
    private double alto;
43
    private double ancho;
44

  
45
    public Size() {
46

  
47
    }
48

  
49
    /**
50
     * Creates a new Size object.
51
     * 
52
     * @param al
53
     *            Altura
54
     * @param an
55
     *            Anchura
56
     */
57
    public Size(double al, double an) {
58
        alto = al;
59
        ancho = an;
60
    }
61

  
62
    /**
63
     * Gets the height of the sheet, measured in centimeters.
64
     * 
65
     * @return Height.
66
     */
67
    public double getHeight() {
68
        return alto;
69
    }
70

  
71
    /**
72
     * Gets the width of the sheet, measured in centimeters.
73
     * 
74
     * @return Width of the sheet.
75
     */
76
    public double getWidth() {
77
        return ancho;
78
    }
79
    
80
    /**
81
     * @deprecated Use {@link #getWidth()} instead
82
     */
83
    @Deprecated
84
    public double getAncho() {
85
    	return getWidth();
86
    }
87
    /**
88
     * @deprecated Use {@link #getHeight()} instead
89
     */
90
    @Deprecated
91
    public double getAlto() {
92
    	return getHeight();
93
    }
94

  
95
    public static void registerPersistent() {
96
        PersistenceManager manager = ToolsLocator.getPersistenceManager();
97
        if (manager.getDefinition(PERSISTENCE_DEFINITION_NAME) == null) {
98
            DynStruct definition =
99
                manager.addDefinition(Size.class, PERSISTENCE_DEFINITION_NAME,
100
                    "Size persistence definition", null, null);
101

  
102
            definition.addDynFieldDouble(HEIGHT_FIELD).setMandatory(true);
103
            definition.addDynFieldDouble(WIDTH_FIELD).setMandatory(true);
104
        }
105
    }
106

  
107
    public void loadFromState(PersistentState state)
108
        throws PersistenceException {
109
        alto = state.getDouble(HEIGHT_FIELD);
110
        ancho = state.getDouble(WIDTH_FIELD);
111
    }
112

  
113
    public void saveToState(PersistentState state) throws PersistenceException {
114
        state.set(HEIGHT_FIELD, alto);
115
        state.set(WIDTH_FIELD, ancho);
116
    }
117
}
tags/org.gvsig.app.document.layout2.app-2.0.245/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/FLayoutZooms.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.Dimension;
25
import java.awt.Point;
26
import java.awt.Toolkit;
27
import java.awt.geom.AffineTransform;
28
import java.awt.geom.Point2D;
29
import java.awt.geom.Rectangle2D;
30
import java.util.prefs.Preferences;
31

  
32
import org.slf4j.Logger;
33
import org.slf4j.LoggerFactory;
34
import org.gvsig.app.project.documents.layout.fframes.IFFrame;
35
import org.gvsig.app.project.documents.layout.fframes.IFFrameUseFMap;
36
import org.gvsig.app.project.documents.layout.gui.LayoutPanel;
37
import org.gvsig.compat.CompatLocator;
38
import org.gvsig.fmap.geom.Geometry.SUBTYPES;
39
import org.gvsig.fmap.geom.GeometryLocator;
40
import org.gvsig.fmap.geom.GeometryManager;
41
import org.gvsig.fmap.geom.exception.CreateEnvelopeException;
42
import org.gvsig.fmap.mapcontext.MapContext;
43
import org.gvsig.tools.observer.Observable;
44
import org.gvsig.tools.observer.ObservableHelper;
45
import org.gvsig.tools.observer.Observer;
46

  
47
/**
48
 * Clase encargada de realizar los zooms al Layout.
49
 * 
50
 * @author Vicente Caballero Navarro
51
 */
52
public class FLayoutZooms implements Observable{
53

  
54
    private static final GeometryManager geomManager = GeometryLocator
55
        .getGeometryManager();
56
    private static final Logger logger = LoggerFactory
57
        .getLogger(FLayoutZooms.class);
58
    private LayoutPanel layout = null;
59
    private ObservableHelper observers;
60
    
61
    public FLayoutZooms(LayoutPanel layoutPanel) {
62
        layout = layoutPanel;
63
        observers = new ObservableHelper();
64
        observers.addObserver(layoutPanel.getLayoutControl());
65
    }
66

  
67
    /**
68
     * Realiza un zoom por rect?ngulo o por punto con un escalado por defecto
69
     * sobre el Layout que se le pasa como par?metro.
70
     * 
71
     * @param p1
72
     *            punto de inicio del rect?ngulo.
73
     * @param p2
74
     *            punto final del rec?ngulo.
75
     */
76
    public void setZoomIn(Point p1, Point p2) {
77
        if (java.lang.Math.abs(layout.getLayoutControl().getFirstPoint().x
78
            - p2.x) < 4) {
79
            double difw = 2;
80
            setZoom(difw, p2);
81
        } else {
82
            if (p1.getX() > p2.getX()) {
83
                int aux = p2.x;
84
                p2.x = p1.x;
85
                p1.x = aux;
86
            }
87

  
88
            if (p1.getY() > p2.getY()) {
89
                int aux = p2.y;
90
                p2.y = p1.y;
91
                p1.y = aux;
92
            }
93

  
94
            Point2D.Double pSheet1 =
95
                FLayoutUtilities.toSheetPoint(
96
                    new Point2D.Double(p1.getX(), p1.getY()), layout
97
                        .getLayoutControl().getAT());
98
            Point2D.Double pSheet2 =
99
                FLayoutUtilities.toSheetPoint(
100
                    new Point2D.Double(p2.getX(), p2.getY()), layout
101
                        .getLayoutControl().getAT());
102

  
103
            double xmin;
104
            double xmax;
105
            double ymin;
106
            double ymax = 0;
107

  
108
            if (pSheet1.x > pSheet2.x) {
109
                xmin = pSheet2.x;
110
                xmax = pSheet1.x;
111
            } else {
112
                xmin = pSheet1.x;
113
                xmax = pSheet2.x;
114
            }
115

  
116
            if (pSheet1.y > pSheet2.y) {
117
                ymin = pSheet2.y;
118
                ymax = pSheet1.y;
119
            } else {
120
                ymin = pSheet1.y;
121
                ymax = pSheet2.y;
122
            }
123

  
124
            Rectangle2D.Double rScreen = new Rectangle2D.Double();
125
            Rectangle2D.Double rSheet = new Rectangle2D.Double();
126
            double x =
127
                FLayoutUtilities.toSheetDistance(layout.getLayoutControl()
128
                    .getRect().getX(), layout.getLayoutControl().getAT());
129
            double y =
130
                FLayoutUtilities.toSheetDistance(layout.getLayoutControl()
131
                    .getRect().getY(), layout.getLayoutControl().getAT());
132
            double w =
133
                FLayoutUtilities.toSheetDistance(layout.getLayoutControl()
134
                    .getRect().getWidth(), layout.getLayoutControl().getAT());
135
            double h =
136
                FLayoutUtilities.toSheetDistance(layout.getLayoutControl()
137
                    .getRect().getHeight(), layout.getLayoutControl().getAT());
138

  
139
            double wv =
140
                FLayoutUtilities.toSheetDistance(layout.getVisibleRect()
141
                    .getWidth(), layout.getLayoutControl().getAT());
142
            double hv =
143
                FLayoutUtilities.toSheetDistance(layout.getVisibleRect()
144
                    .getHeight(), layout.getLayoutControl().getAT());
145
            double mw = xmax - xmin;
146
            double mh = ymax - ymin;
147
            double difw = wv / mw;
148
            double difh = hv / mh;
149

  
150
            if (difw < difh) {
151
                rSheet.x =
152
                    (-xmin * difw)
153
                        - x
154
                        + ((wv - ((pSheet2.getX() - pSheet1.getX()) * difw)) / 2);
155
                rSheet.y =
156
                    (-ymin * difw)
157
                        - y
158
                        + ((hv - ((pSheet2.getY() - pSheet1.getY()) * difw)) / 2);
159

  
160
                rSheet.width = w * difw;
161
                rSheet.height = h * difw;
162
            } else {
163
                rSheet.x =
164
                    (-xmin * difh)
165
                        - x
166
                        + ((wv - ((pSheet2.getX() - pSheet1.getX()) * difh)) / 2);
167
                rSheet.y =
168
                    (-ymin * difh)
169
                        - y
170
                        + ((hv - ((pSheet2.getY() - pSheet1.getY()) * difh)) / 2);
171

  
172
                rSheet.width = w * difh;
173
                rSheet.height = h * difh;
174
            }
175
            setPointsToZoom(p1, p2);
176
            rScreen.setRect(FLayoutUtilities.fromSheetRect(rSheet, layout
177
                .getLayoutControl().getAT()));
178
            if (FLayoutUtilities.isPosible(rScreen)) {
179
                layout.getLayoutControl().setRect(rScreen);
180
            }
181
        }
182
    }
183

  
184
    /**
185
     * Realiza un zoom out sobre el Layout que se le pasa como par?metro.
186
     * 
187
     * @param p2
188
     *            punto central del rect?ngulo.
189
     */
190
    public void setZoomOut(Point p2) {
191
        double difw = 0.5;
192
        setZoom(difw, p2);
193
    }
194

  
195
    /**
196
     * Realiza un zoom out sobre el Layout que se le pasa como par?metro.
197
     * 
198
     * @param dif
199
     *            factor.
200
     * @param p2
201
     *            punto final del rec?ngulo.
202
     */
203
    public void setZoom(double dif, Point p2) {
204
        Point2D.Double pSheet2 =
205
            FLayoutUtilities.toSheetPoint(
206
                new Point2D.Double(p2.getX(), p2.getY()), layout
207
                    .getLayoutControl().getAT());
208
        Rectangle2D.Double rScreen = new Rectangle2D.Double();
209
        Rectangle2D.Double rSheet = new Rectangle2D.Double();
210

  
211
        double difw = dif;
212

  
213
        rSheet.x =
214
            (-pSheet2.getX() * difw)
215
                - FLayoutUtilities.toSheetDistance(layout.getLayoutControl()
216
                    .getRect().getX(), layout.getLayoutControl().getAT())
217
                + FLayoutUtilities.toSheetDistance(layout.getWidth() / 2,
218
                    layout.getLayoutControl().getAT());
219
        rSheet.y =
220
            (-pSheet2.getY() * difw)
221
                - FLayoutUtilities.toSheetDistance(layout.getLayoutControl()
222
                    .getRect().getY(), layout.getLayoutControl().getAT())
223
                + FLayoutUtilities.toSheetDistance(layout.getHeight() / 2,
224
                    layout.getLayoutControl().getAT());
225

  
226
        rSheet.width =
227
            FLayoutUtilities.toSheetDistance(layout.getLayoutControl()
228
                .getRect().getWidth(), layout.getLayoutControl().getAT())
229
                * difw;
230
        rSheet.height =
231
            FLayoutUtilities.toSheetDistance(layout.getLayoutControl()
232
                .getRect().getHeight(), layout.getLayoutControl().getAT())
233
                * difw;
234

  
235
        rScreen.setRect(FLayoutUtilities.fromSheetRect(rSheet, layout
236
            .getLayoutControl().getAT()));
237

  
238
        if (FLayoutUtilities.isPosible(rScreen)) {
239
            layout.getLayoutControl().setRect(rScreen);
240
        }
241

  
242
        // Para realizar el zoom a partir de un punto.
243
        Point p1 =
244
            new Point((int) (p2.getX() - (layout.getWidth() / (difw * 2))),
245
                (int) (p2.getY() - (layout.getHeight() / (difw * 2))));
246
        p2 =
247
            new Point((int) (p2.getX() + (layout.getWidth() / (difw * 2))),
248
                (int) (p2.getY() + (layout.getHeight() / (difw * 2))));
249
        setPointsToZoom(p1, p2);
250
    }
251

  
252
    /**
253
     * Introduce los puntos de control para controlar el zoom del Layout.
254
     */
255
    private void setPointsToZoom(Point p1, Point p2) {
256
        IFFrame[] fframes = layout.getLayoutContext().getFFrames();
257

  
258
        for (int i = 0; i < fframes.length; i++) {
259
            if (fframes[i] instanceof IFFrameUseFMap) {
260
                IFFrameUseFMap fframe = (IFFrameUseFMap) fframes[i];
261
                if (fframe.getATMap() != null) {
262
                    
263
                    Point2D vppo1 = FLayoutUtilities.screenCoordinatesToViewportImageCoordinates(
264
                        p1, fframes[i]);
265
                    Point2D vppo2 = FLayoutUtilities.screenCoordinatesToViewportImageCoordinates(
266
                        p2, fframes[i]);
267
                    
268
                    Point2D px1 =
269
                        FLayoutFunctions.toMapPoint(vppo1, fframe.getATMap());
270
                    Point2D px2 =
271
                        FLayoutFunctions.toMapPoint(vppo2, fframe.getATMap());
272
                    fframe.setPointsToZoom(px1, px2);
273
                }
274
            }
275
        }
276
    }
277

  
278
    /**
279
     * Aplica el zoom real teniendo en cuenta la resoluci?n de pantalla.
280
     */
281
    public void realZoom() {
282
        double cm =
283
            layout.getLayoutContext().getAttributes()
284
                .getPixXCm(layout.getLayoutControl().getRect());
285
        double dpi = CompatLocator.getGraphicsUtils().getScreenDPI();
286
        double dif = (cm * Attributes.PULGADA) / dpi;
287
        setZoom(1 / dif, new Point(layout.getWidth() / 2,
288
            layout.getHeight() / 2));
289
        layout.getLayoutControl().refresh();
290
    }
291

  
292
    /**
293
     * Realiza un zoom in a partir del zoom actual de la vista.
294
     */
295
    public void zoomIn() {
296
        setZoom(2, new Point(layout.getWidth() / 2, layout.getHeight() / 2));
297
        layout.getLayoutControl().refresh();
298
    }
299

  
300
    /**
301
     * Realiza un zoom out a partir del zoom actual de la vista.
302
     */
303
    public void zoomOut() {
304
        setZoom(0.5, new Point(layout.getWidth() / 2, layout.getHeight() / 2));
305
        layout.getLayoutControl().refresh();
306
    }
307

  
308
    /**
309
     * Realiza un zoom a los elementos que esten seleccionados, si no hay
310
     * ning?n elemento seleccionado no realiza ning?n zoom
311
     */
312
    public void zoomSelect() {
313
        Rectangle2D.Double recaux = null;
314
        IFFrame[] fframes = layout.getLayoutContext().getFFrames();
315
        for (int i = 0; i < fframes.length; i++) {
316
            if (fframes[i].getSelected() != IFFrame.NOSELECT) {
317
                if (recaux == null) {
318
                    recaux =
319
                        fframes[i].getBoundingBox(layout.getLayoutControl()
320
                            .getAT());
321
                } else {
322
                    recaux.add(fframes[i].getBoundingBox(layout
323
                        .getLayoutControl().getAT()));
324
                }
325
            }
326
        }
327

  
328
        if (recaux != null) {
329
            Point p1 = new Point((int) recaux.x, (int) recaux.y);
330
            Point p2 =
331
                new Point((int) recaux.getMaxX(), (int) recaux.getMaxY());
332
            setZoomIn(p1, p2);
333
            layout.getLayoutControl().refresh();
334
        }
335
    }
336

  
337
    /**
338
     * Realiza un zoom a todos los elementos del layout.
339
     */
340
    public void zoomAllFrames() {
341
        Rectangle2D.Double recaux = null;
342
        IFFrame[] fframes =
343
            layout.getLayoutControl().getLayoutContext().getFFrames();
344
        for (int i = 0; i < fframes.length; i++) {
345
            if (recaux == null) {
346
                recaux =
347
                    fframes[i]
348
                        .getBoundingBox(layout.getLayoutControl().getAT());
349
            } else {
350
                recaux.add(fframes[i].getBoundingBox(layout.getLayoutControl()
351
                    .getAT()));
352
            }
353
        }
354

  
355
        if (recaux != null) {
356
            Point p1 = new Point((int) recaux.x, (int) recaux.y);
357
            Point p2 =
358
                new Point((int) recaux.getMaxX(), (int) recaux.getMaxY());
359
            setZoomIn(p1, p2);
360
            layout.getLayoutControl().refresh();
361
        }
362
    }
363

  
364
    /**
365
     * Realiza un zoom in a las vista a?adidas al Layout que esten seleccionadas
366
     * 
367
     * @param p1
368
     *            Punto inicial del rect?ngulo
369
     * @param p2
370
     *            Punto final del rect?ngulo
371
     */
372
    public void setViewZoomIn(Point2D poi1, Point2D poi2) {
373
        IFFrame[] fframes = layout.getLayoutContext().getFFrames();
374
        for (int i = 0; i < fframes.length; i++) {
375
            if (fframes[i] instanceof IFFrameUseFMap) {
376
                IFFrameUseFMap fframe = (IFFrameUseFMap) fframes[i];
377

  
378
                if (fframe.isSelected() && fframe.getMapContext()!=null) {
379
                    
380
                    Point2D vppo1 = FLayoutUtilities.screenCoordinatesToViewportImageCoordinates(
381
                        poi1, fframes[i]);
382
                    Point2D vppo2 = FLayoutUtilities.screenCoordinatesToViewportImageCoordinates(
383
                        poi2, fframes[i]);
384
                    
385
                    Point2D.Double mapp1 = FLayoutFunctions.toMapPoint(vppo1, fframe.getATMap());
386
                    Point2D.Double mapp2 = FLayoutFunctions.toMapPoint(vppo2, fframe.getATMap());
387

  
388
                    Rectangle2D.Double r = new Rectangle2D.Double();
389

  
390
                    if (java.lang.Math.abs(poi1.getX() - poi2.getX()) <= 3) {
391
                        double nuevoX;
392
                        double nuevoY;
393
                        double cX;
394
                        double cY;
395

  
396
                        cX = mapp2.getX();
397
                        cY = mapp2.getY();
398

  
399
                        double factor = 1 / MapContext.ZOOMINFACTOR;
400

  
401
                        Rectangle2D extent =
402
                            fframe.getMapContext().getViewPort().getExtent();
403
                        if (extent != null) {
404
                            nuevoX = cX - ((extent.getWidth() * factor) / 2.0);
405
                            nuevoY = cY - ((extent.getHeight() * factor) / 2.0);
406
                            r.x = nuevoX;
407
                            r.y = nuevoY;
408
                            r.width = extent.getWidth() * factor;
409
                            r.height = extent.getHeight() * factor;
410
                        }
411
                    } else {
412
                        // Fijamos el nuevo extent
413
                        r.setFrameFromDiagonal(mapp1, mapp2);
414
                    }
415
                    try {
416
                        fframe.setNewEnvelope(geomManager.createEnvelope(
417
                            r.getX(), r.getY(), r.getMaxX(), r.getMaxY(),
418
                            SUBTYPES.GEOM2D));
419
                    } catch (CreateEnvelopeException e) {
420
                        logger.error("Error creating the envelope", e);
421
                    }
422
                }
423
            }
424
        }
425
    }
426

  
427
    /**
428
     * Realiza un zoom out a las vistas a?adidas al Layout y que est?n
429
     * seleccionadas
430
     * 
431
     * @param p2
432
     *            Punto central
433
     */
434
    public void setViewZoomOut(Point p2) {
435
        Point2D.Double pWorld;
436
        IFFrame[] fframes = layout.getLayoutContext().getFFrames();
437
        for (int i = 0; i < fframes.length; i++) {
438
            if (fframes[i] instanceof IFFrameUseFMap) {
439
                IFFrameUseFMap fframe = (IFFrameUseFMap) fframes[i];
440

  
441
                if (fframe.isSelected() && fframe.getMapContext()!=null) {
442

  
443
                    double nuevoX;
444
                    double nuevoY;
445
                    double cX;
446
                    double cY;
447
                    Point pScreen = new Point((int) p2.getX(), (int) p2.getY());
448
                    
449
                    Point2D vppo1 = FLayoutUtilities.screenCoordinatesToViewportImageCoordinates(
450
                        pScreen, fframes[i]);
451
                    
452
                    pWorld = FLayoutFunctions.toMapPoint(vppo1, fframe.getATMap());
453

  
454
                    cX = pWorld.getX();
455
                    cY = pWorld.getY();
456

  
457
                    double factor = 1 / MapContext.ZOOMOUTFACTOR;
458
                    Rectangle2D extent =
459
                        fframe.getMapContext().getViewPort().getExtent();
460
                    if (extent != null) {
461
                        nuevoX = cX - ((extent.getWidth() * factor) / 2.0);
462
                        nuevoY = cY - ((extent.getHeight() * factor) / 2.0);
463
                        double x = nuevoX;
464
                        double y = nuevoY;
465
                        double width = extent.getWidth() * factor;
466
                        double height = extent.getHeight() * factor;
467
                        try {
468
                            fframe.setNewEnvelope(geomManager.createEnvelope(x,
469
                                y, x + width, y + height, SUBTYPES.GEOM2D));
470
                        } catch (CreateEnvelopeException e) {
471
                            logger.error("Error creating the envelope", e);
472
                        }
473
                    }
474
                }
475
            }
476
        }
477
    }
478

  
479
    /**
480
     * Modifica los puntos de control para generar el zoom del Layout
481
     * 
482
     * @param p1
483
     *            Punto inicial
484
     * @param p2
485
     *            Punto final
486
     */
487
    public void setPan(Point p1, Point p2) {
488
        IFFrame[] fframes = layout.getLayoutContext().getFFrames();
489

  
490
        for (int i = 0; i < fframes.length; i++) {
491
            if (fframes[i] instanceof IFFrameUseFMap) {
492
                IFFrameUseFMap fframe = (IFFrameUseFMap) fframes[i];
493
                if (fframe.getMapContext()!=null) {
494
                	AffineTransform at = fframe.getATMap();
495
                	if (at != null) {
496

  
497
                		Point2D vppo1 = FLayoutUtilities.screenCoordinatesToViewportImageCoordinates(
498
                				p1, fframes[i]);
499
                		Point2D vppo2 = FLayoutUtilities.screenCoordinatesToViewportImageCoordinates(
500
                				p2, fframes[i]);
501

  
502
                		Point2D px1 = FLayoutFunctions.toMapPoint(vppo1, at);
503
                		Point2D px2 = FLayoutFunctions.toMapPoint(vppo2, at);
504
                		fframe.movePoints(px1, px2);
505
                	}
506
                }
507
            }
508
        }
509
    }
510

  
511
    public void addObserver(Observer o) {
512
        observers.addObserver(o);        
513
    }
514

  
515
    public void deleteObserver(Observer o) {
516
      observers.deleteObserver(o);        
517
    }
518

  
519
    public void deleteObservers() {
520
       observers.deleteObservers();        
521
    }
522
}
tags/org.gvsig.app.document.layout2.app-2.0.245/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/FLayoutFunctions.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.Point;
25
import java.awt.Rectangle;
26
import java.awt.geom.AffineTransform;
27
import java.awt.geom.NoninvertibleTransformException;
28
import java.awt.geom.Point2D;
29
import java.awt.geom.Rectangle2D;
30
import java.awt.print.PageFormat;
31

  
32
import org.gvsig.app.project.documents.layout.commands.FrameCommandsRecord;
33
import org.gvsig.app.project.documents.layout.fframes.FFrameGroup;
34
import org.gvsig.app.project.documents.layout.fframes.IFFrame;
35
import org.gvsig.app.project.documents.layout.fframes.IFFrameUseFMap;
36
import org.gvsig.app.project.documents.layout.gui.LayoutPanel;
37
import org.gvsig.fmap.geom.Geometry.SUBTYPES;
38
import org.gvsig.fmap.geom.GeometryLocator;
39
import org.gvsig.fmap.geom.GeometryManager;
40
import org.gvsig.fmap.geom.exception.CreateEnvelopeException;
41
import org.gvsig.fmap.geom.primitive.Envelope;
42
import org.gvsig.tools.observer.Observable;
43
import org.gvsig.tools.observer.ObservableHelper;
44
import org.gvsig.tools.observer.Observer;
45
import org.slf4j.Logger;
46
import org.slf4j.LoggerFactory;
47

  
48
/**
49
 * Funciones utilizadas desde el Layout.
50
 * 
51
 * @author Vicente Caballero Navarro
52
 */
53
public class FLayoutFunctions implements Observable {
54

  
55
    protected static final Logger LOG = LoggerFactory
56
        .getLogger(FLayoutFunctions.class);
57
    private static final GeometryManager geomManager = GeometryLocator
58
        .getGeometryManager();
59
    private static final Logger logger = LoggerFactory
60
        .getLogger(FLayoutFunctions.class);
61
    
62
    private LayoutPanel layout = null;
63
    private ObservableHelper observers;
64
    /**
65
     * Crea un nuevo FLayoutFunctions.
66
     * 
67
     * @param l
68
     *            Referencia al Layout.
69
     */
70
    public FLayoutFunctions(LayoutPanel layoutPanel) {
71
        layout = layoutPanel;
72
        observers = new ObservableHelper();
73
        observers.addObserver(layoutPanel.getLayoutControl());
74
    }
75

  
76
    /**
77
     * Gestiona la herramienta de selecci?n sobre el Mapa.
78
     */
79
    public void setSelect() {
80
        IFFrame fframe = null;
81
        boolean isUpdate = false;
82
        layout.getLayoutContext().updateFFrames();
83
        IFFrame[] fframes = layout.getLayoutContext().getFFrames();
84
        FrameCommandsRecord efs =
85
            layout.getLayoutContext().getFrameCommandsRecord();
86
        efs.startComplex("move");
87
        for (int i = 0; i < fframes.length; i++) {
88
            fframe = fframes[i];
89

  
90
            int difx =
91
                (layout.getLayoutControl().getLastPoint().x - layout
92
                    .getLayoutControl().getFirstPoint().x);
93
            int dify =
94
                (layout.getLayoutControl().getLastPoint().y - layout
95
                    .getLayoutControl().getFirstPoint().y);
96

  
97
            if (((Math.abs(difx) > 3) || (Math.abs(dify) > 3))
98
                && (fframe.getSelected() != IFFrame.NOSELECT)) {
99
                Rectangle2D rectangle = fframe.getLastMoveRect();
100
                if (rectangle == null) {
101
                    efs.endComplex();
102
                    return;
103
                }
104
  
105
                if (fframe instanceof FFrameGroup) {
106
                    ((FFrameGroup) fframe).setAt(layout.getLayoutControl()
107
                        .getAT());
108
                }
109

  
110
                IFFrame fframeAux;
111
                try {
112
                    fframeAux = (IFFrame) fframe.clone();
113
                    fframeAux.setBoundBox(FLayoutUtilities.toSheetRect(
114
                        rectangle, layout.getLayoutControl().getAT()));
115
                    efs.update(fframe, fframeAux);
116
                    fframeAux.getBoundingBox(layout.getLayoutControl().getAT());
117

  
118
                    isUpdate = true;
119
                } catch (CloneNotSupportedException e) {
120
                    LOG.error("It is not possible clonate the object", e);
121
                }
122

  
123
            }
124
            Rectangle rect = null;
125
            if (layout.getLayoutControl().getReSel() == null) {
126
                rect = new Rectangle();
127
                rect.setFrameFromDiagonal(layout.getLayoutControl()
128
                    .getFirstPoint(), layout.getLayoutControl().getLastPoint());
129
            } else {
130
                rect = layout.getLayoutControl().getReSel();
131
            }
132
            if (layout.getLayoutControl().isReSel()
133
                && (rect.contains(fframe.getBoundingBox(layout
134
                    .getLayoutControl().getAT())))) {
135
                fframe.setSelected(true);
136
            }
137

  
138
            if (isUpdate) {
139
                observers.notifyObservers(this, 
140
                    new DefaultLayoutNotification(LayoutNotification.LAYOUT_INVALIDATED));
141
            } else {
142
                observers.notifyObservers(this, 
143
                    new DefaultLayoutNotification(LayoutNotification.LAYOUT_VALIDATED));
144
            }
145
        }
146
        efs.endComplex();
147
        layout.getLayoutContext().updateFFrames();
148
    }
149

  
150
    /**
151
     * Pan sobre la vista del FFrameView.
152
     * 
153
     * @param p1
154
     *            Punto inicial del desplazamiento.
155
     * @param p2
156
     *            Punto final del desplazamiento.
157
     */
158
    public void setViewPan(Point p1, Point p2) {
159
        IFFrame[] fframes = layout.getLayoutContext().getFFrames();
160
        for (int i = 0; i < fframes.length; i++) {
161
            if (fframes[i] instanceof IFFrameUseFMap) {
162
                IFFrameUseFMap fframe = (IFFrameUseFMap) fframes[i];
163

  
164
                if (((IFFrame) fframe).getSelected() != IFFrame.NOSELECT) {
165
                    if (fframe.getATMap() != null) {
166
                        Rectangle2D.Double r = new Rectangle2D.Double();
167
                        Envelope envel =
168
                            // fframe.getMapContext().getViewPort().getExtent();
169
                            fframe.getMapContext().getViewPort().getEnvelope();
170
                        
171
                        if (envel != null) {
172
                            double visible_factor = screenPixelToViewPortPixelRatio(
173
                                layout,
174
                                ((IFFrame) fframe).getBoundBox().getHeight(),
175
                                fframe.getMapContext().getViewPort().getImageHeight());
176

  
177
                            Point p1scaled = new Point(
178
                                (int) (visible_factor * p1.getX()),
179
                                (int) (visible_factor * p1.getY()));
180
                            Point p2scaled = new Point(
181
                                (int) (visible_factor * p2.getX()),
182
                                (int) (visible_factor * p2.getY()));
183
                            
184
                            Point2D mp1 = toMapPoint(p1scaled, fframe.getATMap());
185
                            Point2D mp2 = toMapPoint(p2scaled, fframe.getATMap());
186
                            double x =
187
                                envel.getMinimum(0) - (mp2.getX() - mp1.getX());
188
                            double y =
189
                                envel.getMinimum(1) - (mp2.getY() - mp1.getY());
190
                            double width = envel.getLength(0);
191
                            double height = envel.getLength(1);
192
                            try {
193
                                fframe
194
                                    .getMapContext()
195
                                    .getViewPort()
196
                                    .setEnvelope(
197
                                        geomManager.createEnvelope(x, y, x
198
                                            + width, y + height,
199
                                            SUBTYPES.GEOM2D));
200
                            } catch (CreateEnvelopeException e) {
201
                                logger.error("Error creating the envelope", e);
202
                            }
203
                            fframe.refresh();
204
                            if (fframe.getExtentSynced()) {
205
                                fframe.refreshOriginalExtent();
206
                            }
207
                        }
208
                    }
209
                }
210
            }
211
        }
212
    }
213

  
214
    public void setScale(long scale) {
215
    	IFFrameUseFMap[] selectedFrames = layout.getLayoutContext().getSelectedFFrames(IFFrameUseFMap.class);
216
    	if (selectedFrames.length==1) {
217
    		IFFrameUseFMap fframe = (IFFrameUseFMap) selectedFrames[0];
218
    		fframe.setScale(scale);
219
    		// FIXME CMI: needed?? fframe.refresh();
220
    	}
221
    }
222

  
223
    public void addLayer() {
224
    	
225
    }
226
    
227
    /**
228
     * Devuelve un punto real a partir de un punto en pixels sobre la vista.
229
     * 
230
     * @param pScreen
231
     *            Punto en pixels.
232
     * @param at1
233
     *            Matriz de transformaci?n.
234
     * 
235
     * @return Punto real.
236
     */
237
    public static Point2D.Double toMapPoint(Point2D pScreen, AffineTransform at1) {
238
        Point2D.Double pWorld = new Point2D.Double();
239

  
240
        AffineTransform at;
241

  
242
        try {
243
            at = at1.createInverse();
244
            at.transform(pScreen, pWorld);
245
        } catch (NoninvertibleTransformException e) {
246
            // throw new RuntimeException(e);
247
        }
248

  
249
        return pWorld;
250
    }
251

  
252
    public void addObserver(Observer o) {
253
        observers.addObserver(o);        
254
    }
255

  
256
    public void deleteObserver(Observer o) {
257
      observers.deleteObserver(o);        
258
    }
259

  
260
    public void deleteObservers() {
261
       observers.deleteObservers();        
262
    }
263
    
264
    /**
265
     * Gets the proportion between the number of pixels used
266
     * on the screen (physical pixels) and the "logical" pixels
267
     * used in the viewport of a frame (imageHeight, etc).
268
     * 
269
     * For example if viewport image height is 500
270
     * and the frame actually needs 100 pixels in height
271
     * (due to zooming) then this method returns 5.
272
     *  
273
     * @param lyt_panel
274
     * @param frame_height_cm frame height in cm
275
     * @param frame_vp_img_height frame viewport image height (pixels)
276
     * @return
277
     */
278
    public static double screenPixelToViewPortPixelRatio(
279
        LayoutPanel lyt_panel, double frame_height_cm, int frame_vp_img_height) {
280
        
281
        double sheet_height_screen_pix = lyt_panel.getLayoutControl().getRect().getHeight();
282
        int ori = lyt_panel.getLayoutContext().getAttributes().getPageFormat().getOrientation();
283
        double paper_h_i72 = 0;
284
        
285
        /*
286
         * Javadoc says getPageFormat().getWidth()(getHeight()
287
         * take into account orientation
288
         * but apparently it's not like that
289
         */
290
        if (ori == PageFormat.LANDSCAPE || ori == PageFormat.REVERSE_LANDSCAPE) {
291
            paper_h_i72 = lyt_panel.getLayoutContext().getAttributes().getPageFormat().getWidth();
292
        } else {
293
            paper_h_i72 = lyt_panel.getLayoutContext().getAttributes().getPageFormat().getHeight();
294
        }
295
        
296
        /*
297
         * page format uses old unit (inch/72)
298
         */
299
        double paper_h_cm = (2.54 / 72.0) * paper_h_i72;
300
        double frame_part = frame_height_cm / paper_h_cm;
301
        double pixels_fview_screen_h = sheet_height_screen_pix * frame_part;   
302
        double pixels_fview_vp_h = 1.0 * frame_vp_img_height;
303
        return pixels_fview_vp_h / pixels_fview_screen_h;
304
    }
305
    
306

  
307
    public static String getLastMessage(Throwable ex) {
308
        
309
        if (ex == null) {
310
            return "[null]";
311
        }
312
        
313
        Throwable p = ex;
314
        while (p.getCause() != null && p.getCause() != p) {
315
            p = p.getCause();
316
        }
317
        return p.getMessage();
318
    }
319
}
tags/org.gvsig.app.document.layout2.app-2.0.245/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/LayoutDocument.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.util.Iterator;
25
import org.gvsig.app.project.documents.Document;
26

  
27
/**
28
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
29
 */
30
public interface LayoutDocument extends Document {
31

  
32
    public LayoutContext getLayoutContext();
33
   
34
    /**
35
     * Get an Iterator over al elements in the layout.
36
     * 
37
     * @return 
38
     */
39
    public Iterator deepiterator();
40

  
41
    public Iterator iterator();
42
    
43
}
tags/org.gvsig.app.document.layout2.app-2.0.245/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/DefaultLayoutManager.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
import java.lang.reflect.Array;
26
import java.text.NumberFormat;
27
import java.util.ArrayList;
28
import java.util.Arrays;
29
import java.util.Comparator;
30
import java.util.Iterator;
31
import java.util.List;
32

  
33
import javax.swing.ImageIcon;
34

  
35
import org.gvsig.andami.PluginServices;
36
import org.gvsig.andami.PluginsLocator;
37
import org.gvsig.andami.messages.NotificationManager;
38
import org.gvsig.andami.ui.mdiManager.IWindow;
39
import org.gvsig.app.ApplicationLocator;
40
import org.gvsig.app.gui.preferencespage.PreferenceKeys;
41
import org.gvsig.app.project.ProjectManager;
42
import org.gvsig.app.project.documents.AbstractDocument;
43
import org.gvsig.app.project.documents.AbstractDocumentManager;
44
import org.gvsig.app.project.documents.Document;
45
import org.gvsig.app.project.documents.actions.CopyDocumentAction;
46
import org.gvsig.app.project.documents.actions.CutDocumentAction;
47
import org.gvsig.app.project.documents.actions.PasteDocumentAction;
48
import org.gvsig.app.project.documents.gui.WindowLayout;
49
import org.gvsig.app.project.documents.layout.contextmenu.gui.AbstractLayoutContextMenuAction;
50
import org.gvsig.app.project.documents.layout.fframes.FrameFactory;
51
import org.gvsig.app.project.documents.layout.fframes.IFFrame;
52
import org.gvsig.app.project.documents.layout.fframes.gui.dialogs.IFFrameDialog;
53
import org.gvsig.app.project.documents.layout.gui.DefaultLayoutPanel;
54
import org.gvsig.app.project.documents.layout.gui.LayoutPanel;
55
import org.gvsig.app.project.documents.layout.gui.LayoutPanelImpl;
56
import org.gvsig.app.project.documents.layout.gui.MapProperties;
57
import org.gvsig.app.project.documents.layout.gui.dialogs.FConfigLayoutDialog;
58
import org.gvsig.app.project.documents.view.IContextMenuAction;
59
import org.gvsig.tools.ToolsLocator;
60
import org.gvsig.tools.dynobject.DynStruct;
61
import org.gvsig.tools.extensionpoint.ExtensionPoint;
62
import org.gvsig.tools.extensionpoint.ExtensionPoint.Extension;
63
import org.gvsig.tools.extensionpoint.ExtensionPointManager;
64
import org.gvsig.tools.persistence.PersistenceManager;
65
import org.gvsig.tools.swing.api.ToolsSwingLocator;
66
import org.gvsig.utils.XMLEntity;
67
import org.slf4j.Logger;
68
import org.slf4j.LoggerFactory;
69

  
70
/**
71
 * Factory of maps.
72
 * 
73
 * @author Vicente Caballero Navarro
74
 */
75
public class DefaultLayoutManager extends AbstractDocumentManager implements
76
    LayoutManager {
77
    static final Logger LOG = LoggerFactory
78
        .getLogger(DefaultLayoutManager.class);
79

  
80
    static final String KEY_LAYOUT_FFRAMEDIALOG =
81
        "app.project.documents.layout.fframes.gui";
82
    static final String KEY_LAYOUT_FFRAME =
83
        "app.project.documents.layout.fframes";
84

  
85
    public static final String PERSISTENCE_LAYOUT_DOCUMENT_DEFINITION_NAME =
86
        "LayoutDocument";
87
    
88
    private static final String LAYOUT_CONTEXT_MENUS = "Layout_ContextMenus";
89

  
90
    ExtensionPointManager extensionPoints = ToolsLocator
91
        .getExtensionPointManager();
92

  
93
    private Boolean defaultShowGrid = null;
94
    private Boolean defaultAdjustToGrid = null;
95
    private Boolean defaultShowRulers = null;
96

  
97
    private DynStruct persistenceDefinition;
98

  
99
    /**
100
     * Returns image of button.
101
     * 
102
     * @return Image button.
103
     */
104
    public ImageIcon getIcon() {
105
    	return ToolsSwingLocator.getIconThemeManager().getCurrent().get("document-map-icon");
106
    }
107

  
108
    /**
109
     * Returns image of selected button.
110
     * 
111
     * @return Image button.
112
     */
113
    public ImageIcon getIconSelected() {
114
        return ToolsSwingLocator.getIconThemeManager().getCurrent().get("document-map-icon-sel");
115
    }
116

  
117
    /**
118
     * Returns the name of registration in the point of extension.
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff