Revision 416

View differences:

tags/org.gvsig.app.document.layout.app-2.0.27/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
    <modelVersion>4.0.0</modelVersion>
3
    <artifactId>org.gvsig.app.document.layout.app</artifactId>
4
    <packaging>pom</packaging>
5
    <version>2.0.27</version>
6
    <name>Document: Layout document support</name>
7
    <description>This plugin adds creation/management of layout (map) documents.</description>
8
    <parent>
9
        <groupId>org.gvsig</groupId>
10
        <artifactId>org.gvsig.desktop</artifactId>
11
        <version>2.0.101</version>
12
    </parent>
13
    <url>https://devel.gvsig.org/redmine/projects/gvsig-app-document-layout</url>
14
    <scm>
15
        <connection>scm:svn:https://devel.gvsig.org/svn/gvsig-app-document-layout/tags/org.gvsig.app.document.layout.app-2.0.27</connection>
16
        <developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-app-document-layout/tags/org.gvsig.app.document.layout.app-2.0.27</developerConnection>
17
        <url>https://devel.gvsig.org/redmine/projects/gvsig-app-document-layout/repository/show/tags/org.gvsig.app.document.layout.app-2.0.27</url>
18
    </scm>
19
    <repositories>
20
      <repository>
21
        <id>gvsig-public-http-repository</id>
22
        <name>gvSIG maven public HTTP repository</name>
23
        <url>http://devel.gvsig.org/m2repo/j2se</url>
24
        <releases>
25
          <enabled>true</enabled>
26
          <updatePolicy>daily</updatePolicy>
27
          <checksumPolicy>warn</checksumPolicy>
28
        </releases>
29
        <snapshots>
30
          <enabled>true</enabled>
31
          <updatePolicy>daily</updatePolicy>
32
          <checksumPolicy>warn</checksumPolicy>
33
        </snapshots>
34
      </repository>
35
    </repositories>
36
        
37
	<build>
38
		<plugins>
39
			<plugin>
40
				<groupId>org.apache.maven.plugins</groupId>
41
				<artifactId>maven-release-plugin</artifactId>
42
				<configuration>
43
					<tagBase>https://devel.gvsig.org/svn/gvsig-app-document-layout/tags</tagBase>
44
				</configuration>
45
			</plugin>
46
		</plugins>
47
	</build>
48

  
49
	<modules>
50
		<module>org.gvsig.app.document.layout.app.mainplugin</module>
51
	</modules>
52

  
53
</project>
tags/org.gvsig.app.document.layout.app-2.0.27/org.gvsig.app.document.layout.app.mainplugin/buildNumber.properties
1
#Fri Jul 03 20:25:14 CEST 2015
2
buildNumber=41
tags/org.gvsig.app.document.layout.app-2.0.27/org.gvsig.app.document.layout.app.mainplugin/src/test/resources/README.txt
1
Put into this folder the resources needed by your test classes.
2

  
3
This folder is added to the Tests classpath, so you can load any resources 
4
through the ClassLoader.
5

  
6
By default, in this folder you can find an example of log4j configuration,
7
prepared to log messages through the console, so logging works when you
8
run your tests classes.
tags/org.gvsig.app.document.layout.app-2.0.27/org.gvsig.app.document.layout.app.mainplugin/src/test/resources/log4j.xml
1
<?xml version="1.0" encoding="ISO-8859-1" ?>
2
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
3

  
4
<!-- 
5
Log4J configuration file for unit tests execution.
6
 -->
7
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
8

  
9
	<!-- Appender configuration to show logging messages through the console -->
10
	<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
11
		<layout class="org.apache.log4j.PatternLayout">
12
			<param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p [%c{2}.%M()]\n  %m%n" />
13
		</layout>
14
	</appender>
15

  
16
	<!-- 
17
	Activate logging messages of DEBUG level of higher only for the
18
	org.gvsig.tools packages.
19
	You can put full classes names or packages instead, to configure
20
	logging for all the classes and subpackages of the package.
21
	-->
22
	<category name="org.gvsig.tools">
23
		<priority value="DEBUG" />
24
	</category>
25
	<category name="org.gvsig.app.document.layout">
26
		<priority value="DEBUG" />
27
	</category>
28

  
29
	<!-- 
30
	By default, show only logging messages of INFO level or higher, 
31
	through the previously configured CONSOLE appender. 
32
	-->
33
	<root>
34
		<priority value="INFO" />
35
		<appender-ref ref="CONSOLE" />
36
	</root>
37
</log4j:configuration>
0 38

  
tags/org.gvsig.app.document.layout.app-2.0.27/org.gvsig.app.document.layout.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.layout.app-2.0.27/org.gvsig.app.document.layout.app.mainplugin/src/main/java/org/gvsig/app/document/layout/app/mainplugin/package.html
1
<?xml version="1.0" encoding="UTF-8" ?>
2
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
<html xmlns="http://www.w3.org/1999/xhtml">
4
<head>
5
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6
<title>org.gvsig.landregistryviewer package documentation</title>
7
</head>
8
<body>
9

  
10
	<p>LandRegistryViewer gvSIG extension</p>
11
	
12
	<p>
13
	Shows LandRegistryViewer into gvSIG.
14
	</p>
15

  
16
</body>
17
</html>
0 18

  
tags/org.gvsig.app.document.layout.app-2.0.27/org.gvsig.app.document.layout.app.mainplugin/src/main/java/org/gvsig/app/gui/preferencespage/PrintPropertiesPage.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.gui.preferencespage;
23

  
24
import java.awt.Dimension;
25
import java.awt.GridLayout;
26

  
27
import javax.swing.ButtonGroup;
28
import javax.swing.ImageIcon;
29
import javax.swing.JCheckBox;
30
import javax.swing.JLabel;
31
import javax.swing.JPanel;
32
import javax.swing.JRadioButton;
33
import javax.swing.JTextField;
34

  
35
import org.gvsig.andami.PluginServices;
36
import org.gvsig.andami.preferences.AbstractPreferencePage;
37
import org.gvsig.andami.preferences.StoreException;
38

  
39
public class PrintPropertiesPage extends AbstractPreferencePage {
40

  
41
    private static final long serialVersionUID = 5806304468312341691L;
42
    private static final boolean FACTORY_DEFAULT_LANDSCAPED_PAGE = true;
43
    protected static String id = PrintPropertiesPage.class.getName();
44
    private ImageIcon icon;
45
    private JRadioButton rdBtnPortraitPage;
46
    private JRadioButton rdBtnLandscapePage;
47
    private JCheckBox chkCustomMargins;
48
    private JTextField txtTopMargin;
49
    private JTextField txtLeftMargin;
50
    private JTextField txtBottomMargin;
51
    private JTextField txtRightMargin;
52

  
53
    public PrintPropertiesPage() {
54
        super();
55
        setParentID(LayoutPage.class.getName());
56
        icon = PluginServices.getIconTheme().get("prepare-page-icon");
57
        rdBtnPortraitPage =
58
            new JRadioButton(PluginServices.getText(this,
59
                "options.layout.paper_properties.portrait"));
60
        ImageIcon portrait =
61
            PluginServices.getIconTheme().get("portrait-page-setup");
62
        rdBtnLandscapePage =
63
            new JRadioButton(PluginServices.getText(this,
64
                "options.layout.paper_properties.landscaped"));
65
        ImageIcon landscape =
66
            PluginServices.getIconTheme().get("landscape-page-setup");
67

  
68
        ButtonGroup group = new ButtonGroup();
69
        group.add(rdBtnLandscapePage);
70
        group.add(rdBtnPortraitPage);
71

  
72
        JPanel aux = new JPanel(new GridLayout(2, 2, 10, 0));
73
        aux.setPreferredSize(new Dimension(200, 150));
74
        aux.setSize(200, 150);
75
        aux.add(new JLabel(landscape));
76
        aux.add(new JLabel(portrait));
77
        aux.add(rdBtnLandscapePage);
78
        aux.add(rdBtnPortraitPage);
79

  
80
        addComponent(new JLabel(PluginServices.getText(this,
81
            "options.layout.paper_properties.paper_direction")));
82
        addComponent("", aux);
83
        addComponent(chkCustomMargins =
84
            new JCheckBox(PluginServices.getText(this, "personalizar_margenes")));
85

  
86
        JPanel aux2 = new JPanel(new GridLayout(2, 4, 10, 3));
87
        aux2.add(new JLabel(PluginServices.getText(this, "Superior")));
88
        aux2.add(txtTopMargin = new JTextField(10));
89
        aux2.add(new JLabel(PluginServices.getText(this, "Izquierdo")));
90
        aux2.add(txtLeftMargin = new JTextField(10));
91
        aux2.add(new JLabel(PluginServices.getText(this, "Inferior")));
92
        aux2.add(txtBottomMargin = new JTextField(10));
93
        aux2.add(new JLabel(PluginServices.getText(this, "Derecho")));
94
        aux2.add(txtRightMargin = new JTextField(10));
95
        addComponent("", aux2);
96
    }
97

  
98
    public void storeValues() throws StoreException {
99
        // TODO Auto-generated method stub
100

  
101
    }
102

  
103
    public void setChangesApplied() {
104
        // TODO Auto-generated method stub
105

  
106
    }
107

  
108
    public String getID() {
109
        return id;
110
    }
111

  
112
    public String getTitle() {
113
        return PluginServices.getText(this,
114
            "options.layout.paper_properties.title");
115
    }
116

  
117
    public JPanel getPanel() {
118
        return this;
119
    }
120

  
121
    public void initializeValues() {
122
        // TODO Auto-generated method stub
123

  
124
    }
125

  
126
    public void initializeDefaults() {
127
        rdBtnLandscapePage.setSelected(FACTORY_DEFAULT_LANDSCAPED_PAGE);
128
        rdBtnPortraitPage.setSelected(!FACTORY_DEFAULT_LANDSCAPED_PAGE);
129
    }
130

  
131
    public ImageIcon getIcon() {
132
        return icon;
133
    }
134

  
135
    public boolean isValueChanged() {
136
        // TODO Auto-generated method stub
137
        return false;
138
    }
139

  
140
}
tags/org.gvsig.app.document.layout.app-2.0.27/org.gvsig.app.document.layout.app.mainplugin/src/main/java/org/gvsig/app/gui/preferencespage/LayoutPage.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.gui.preferencespage;
23

  
24
import javax.swing.ImageIcon;
25
import javax.swing.JCheckBox;
26
import javax.swing.JPanel;
27
import javax.swing.JTextField;
28

  
29
import org.gvsig.andami.IconThemeHelper;
30
import org.gvsig.andami.PluginServices;
31
import org.gvsig.andami.preferences.AbstractPreferencePage;
32
import org.gvsig.andami.preferences.StoreException;
33
import org.gvsig.app.project.ProjectManager;
34
import org.gvsig.app.project.documents.layout.Attributes;
35
import org.gvsig.app.project.documents.layout.DefaultLayoutManager;
36
import org.gvsig.utils.XMLEntity;
37

  
38
/**
39
 * Layout preference page where the user can establish default values for
40
 * <ol>
41
 * <li><b>grid horizontal gap</b></li>
42
 * <li><b>grid vertical gap</b></li>
43
 * <li><b>show or hide grid</b></li>
44
 * <li><b>adjust elements to grid</b></li>
45
 * <li><b>show or hide rules</b></li>
46
 * </ol>
47
 * 
48
 * @author jaume dominguez faus - jaume.dominguez@iver.es
49
 * 
50
 */
51
public class LayoutPage extends AbstractPreferencePage {
52

  
53
    private static final long serialVersionUID = -8225970409668105935L;
54
    private static final boolean FACTORY_DEFAULT_LAYOUT_ENABLE_RULES = true;
55
    private static final boolean FACTORY_DEFAULT_LAYOUT_GRID_SHOW = true;
56
    private static final double FACTORY_DEFAULT_VERTICAL_GAP = 1;
57
    private static final double FACTORY_DEFAULT_HORIZONTAL_GAP = 1;
58
    private static final boolean FACTORY_DEFAULT_LAYOUT_GRID_ENABLE = false;
59
    private static final String DEFAULT_SHOW_LAYOUT_GRID_KEY_NAME =
60
        "DefaultShowLayoutGrid";
61
    private static final String DEFAULT_ENABLE_LAYOUT_GRID_KEY_NAME =
62
        "DefaultEnableLayoutGrid";
63
    private static final String DEFAULT_SHOW_LAYOUT_RULES_KEY_NAME =
64
        "DefaultShowLayoutRules";
65
    private static final String DEFAULT_LAYOUT_GRID_VERTICAL_GAP_KEY_NAME =
66
        "DefaultGridVerticalGap";
67
    private static final String DEFAULT_LAYOUT_GRID_HORIZONTAL_GAP_KEY_NAME =
68
        "DefaultGridHorizontalGap";
69
    static String id = LayoutPage.class.getName();;
70
    private ImageIcon icon;
71
    private JCheckBox chkGridEnabled;
72
    private JCheckBox chkShowRules;
73
    private JCheckBox chkShowGrid;
74
    private JTextField txtVGap;
75
    private JTextField txtHGap;
76

  
77
    private static DefaultLayoutManager layoutManager = null;
78

  
79
    /**
80
     * Builds preference page where the user can establish default values for
81
     * <ol>
82
     * <li><b>grid horizontal gap</b></li>
83
     * <li><b>grid vertical gap</b></li>
84
     * <li><b>show or hide grid</b></li>
85
     * <li><b>adjust elements to grid</b></li>
86
     * <li><b>show or hide rules</b></li>
87
     * </ol>
88
     */
89
    public LayoutPage() {
90
        super();
91
        layoutManager =
92
            (DefaultLayoutManager) ProjectManager.getInstance()
93
                .getDocumentManager(DefaultLayoutManager.TYPENAME);
94

  
95
        icon = IconThemeHelper.getImageIcon("document-map-icon");
96

  
97
        // horizontal gap text field
98
        addComponent(PluginServices.getText(this, "espaciado_horizontal"),
99
            txtHGap = new JTextField(5));
100

  
101
        // vertical gap text field
102
        addComponent(PluginServices.getText(this, "espaciado_vertical"),
103
            txtVGap = new JTextField(5));
104

  
105
        // show/hide show check
106
        addComponent(chkShowGrid =
107
            new JCheckBox(PluginServices.getText(this, "visualizar_cuadricula")));
108

  
109
        // enable/disable grid
110
        addComponent(chkGridEnabled =
111
            new JCheckBox(PluginServices.getText(this, "malla_activada")));
112

  
113
        // show/hide rules
114
        addComponent(chkShowRules =
115
            new JCheckBox(PluginServices.getText(this, "activar_regla")));
116

  
117
    }
118

  
119
    public void storeValues() throws StoreException {
120
        double hGap, vGap;
121
        boolean gridEnabled, showRules, showGrid;
122
        try {
123
            hGap = Double.parseDouble(txtHGap.getText());
124
            vGap = Double.parseDouble(txtVGap.getText());
125
            gridEnabled = chkGridEnabled.isSelected();
126
            showGrid = chkShowGrid.isSelected();
127
            showRules = chkShowRules.isSelected();
128
        } catch (Exception e) {
129
            throw new StoreException(PluginServices.getText(this,
130
                "invalid_value_for_gap"));
131
        }
132
        layoutManager.setDefaultShowGrid(showGrid);
133
        layoutManager.setDefaultAdjustToGrid(gridEnabled);
134
        layoutManager.setDefaultShowRulers(showRules);
135
        Attributes.setDefaultGridGap(hGap, vGap);
136
        PluginServices ps = PluginServices.getPluginServices(this);
137
        XMLEntity xml = ps.getPersistentXML();
138
        xml.putProperty(DEFAULT_LAYOUT_GRID_HORIZONTAL_GAP_KEY_NAME, hGap);
139
        xml.putProperty(DEFAULT_LAYOUT_GRID_VERTICAL_GAP_KEY_NAME, vGap);
140
        xml.putProperty(DEFAULT_SHOW_LAYOUT_GRID_KEY_NAME, showGrid);
141
        xml.putProperty(DEFAULT_ENABLE_LAYOUT_GRID_KEY_NAME, gridEnabled);
142
        xml.putProperty(DEFAULT_SHOW_LAYOUT_RULES_KEY_NAME, showRules);
143
    }
144

  
145
    public String getID() {
146
        return id;
147
    }
148

  
149
    public String getTitle() {
150
        return PluginServices.getText(this, "Mapa");
151
    }
152

  
153
    public JPanel getPanel() {
154
        return this;
155
    }
156

  
157
    public void initializeValues() {
158
        PluginServices ps = PluginServices.getPluginServices(this);
159
        XMLEntity xml = ps.getPersistentXML();
160
        double hGap = FACTORY_DEFAULT_HORIZONTAL_GAP;
161
        double vGap = FACTORY_DEFAULT_VERTICAL_GAP;
162
        boolean showGrid = FACTORY_DEFAULT_LAYOUT_GRID_SHOW;
163
        boolean gridEnabled = FACTORY_DEFAULT_LAYOUT_GRID_ENABLE;
164
        boolean showRules = FACTORY_DEFAULT_LAYOUT_ENABLE_RULES;
165
        // horizontal gap
166
        if (xml.contains(DEFAULT_LAYOUT_GRID_HORIZONTAL_GAP_KEY_NAME)) {
167
            hGap =
168
                xml.getDoubleProperty(DEFAULT_LAYOUT_GRID_HORIZONTAL_GAP_KEY_NAME);
169
        }
170
        txtHGap.setText(String.valueOf(hGap));
171

  
172
        // vertical gap
173
        if (xml.contains(DEFAULT_LAYOUT_GRID_VERTICAL_GAP_KEY_NAME)) {
174
            vGap =
175
                xml.getDoubleProperty(DEFAULT_LAYOUT_GRID_VERTICAL_GAP_KEY_NAME);
176
        }
177
        txtVGap.setText(String.valueOf(vGap));
178

  
179
        // show/hide grid check
180
        if (xml.contains(DEFAULT_SHOW_LAYOUT_GRID_KEY_NAME)) {
181
            showGrid =
182
                xml.getBooleanProperty(DEFAULT_SHOW_LAYOUT_GRID_KEY_NAME);
183
        }
184
        chkShowGrid.setSelected(showGrid);
185

  
186
        // enable/disable grid check
187
        if (xml.contains(DEFAULT_ENABLE_LAYOUT_GRID_KEY_NAME)) {
188
            gridEnabled =
189
                xml.getBooleanProperty(DEFAULT_ENABLE_LAYOUT_GRID_KEY_NAME);
190
        }
191
        chkGridEnabled.setSelected(gridEnabled);
192

  
193
        // enable/disable rules
194
        if (xml.contains(DEFAULT_SHOW_LAYOUT_RULES_KEY_NAME)) {
195
            showRules =
196
                xml.getBooleanProperty(DEFAULT_SHOW_LAYOUT_RULES_KEY_NAME);
197
        }
198
        chkShowRules.setSelected(showRules);
199

  
200
        layoutManager.setDefaultShowGrid(showGrid);
201
        layoutManager.setDefaultAdjustToGrid(gridEnabled);
202
        layoutManager.setDefaultShowRulers(showRules);
203
        Attributes.setDefaultGridGap(hGap, vGap);
204
    }
205

  
206
    public void initializeDefaults() {
207
        txtHGap.setText(String.valueOf(FACTORY_DEFAULT_HORIZONTAL_GAP));
208
        txtVGap.setText(String.valueOf(FACTORY_DEFAULT_VERTICAL_GAP));
209
        chkShowGrid.setSelected(FACTORY_DEFAULT_LAYOUT_GRID_SHOW);
210
        chkGridEnabled.setSelected(FACTORY_DEFAULT_LAYOUT_GRID_ENABLE);
211
        chkShowRules.setSelected(FACTORY_DEFAULT_LAYOUT_ENABLE_RULES);
212
    }
213

  
214
    public ImageIcon getIcon() {
215
        return icon;
216
    }
217

  
218
    public boolean isValueChanged() {
219
        return super.hasChanged();
220
    }
221

  
222
    public void setChangesApplied() {
223
        setChanged(false);
224
    }
225
}
0 226

  
tags/org.gvsig.app.document.layout.app-2.0.27/org.gvsig.app.document.layout.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

  
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.layout.app-2.0.27/org.gvsig.app.document.layout.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
     * Devuelve el alto del folio.
64
     * 
65
     * @return altura.
66
     */
67
    public double getAlto() {
68
        return alto;
69
    }
70

  
71
    /**
72
     * Devuelve la anchura del folio.
73
     * 
74
     * @return Anchura.
75
     */
76
    public double getAncho() {
77
        return ancho;
78
    }
79

  
80
    public static void registerPersistent() {
81
        PersistenceManager manager = ToolsLocator.getPersistenceManager();
82
        if (manager.getDefinition(PERSISTENCE_DEFINITION_NAME) == null) {
83
            DynStruct definition =
84
                manager.addDefinition(Size.class, PERSISTENCE_DEFINITION_NAME,
85
                    "Size persistence definition", null, null);
86

  
87
            definition.addDynFieldDouble(HEIGHT_FIELD).setMandatory(true);
88
            definition.addDynFieldDouble(WIDTH_FIELD).setMandatory(true);
89
        }
90
    }
91

  
92
    public void loadFromState(PersistentState state)
93
        throws PersistenceException {
94
        alto = state.getDouble(HEIGHT_FIELD);
95
        ancho = state.getDouble(WIDTH_FIELD);
96
    }
97

  
98
    public void saveToState(PersistentState state) throws PersistenceException {
99
        state.set(HEIGHT_FIELD, alto);
100
        state.set(WIDTH_FIELD, ancho);
101
    }
102
}
tags/org.gvsig.app.document.layout.app-2.0.27/org.gvsig.app.document.layout.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().getRect().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().getRect().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 (((IFFrame) fframe).getSelected() != IFFrame.NOSELECT) {
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
                    // Borramos el anterior
389
                    observers.notifyObservers(this, 
390
                        new DefaultLayoutNotification(LayoutNotification.LAYOUT_INVALIDATED));
391
                    Rectangle2D.Double r = new Rectangle2D.Double();
392

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

  
399
                        cX = mapp2.getX();
400
                        cY = mapp2.getY();
401

  
402
                        double factor = 1 / MapContext.ZOOMINFACTOR;
403

  
404
                        Rectangle2D extent =
405
                            fframe.getMapContext().getViewPort().getExtent();
406
                        if (extent != null) {
407
                            nuevoX = cX - ((extent.getWidth() * factor) / 2.0);
408
                            nuevoY = cY - ((extent.getHeight() * factor) / 2.0);
409
                            r.x = nuevoX;
410
                            r.y = nuevoY;
411
                            r.width = extent.getWidth() * factor;
412
                            r.height = extent.getHeight() * factor;
413
                        }
414

  
415
                        // fframeAux.setNewExtent(r);
416
                    } else {
417
                        // Fijamos el nuevo extent
418

  
419
                        r.setFrameFromDiagonal(mapp1, mapp2);
420

  
421
                        // fframeAux.setNewExtent(r);
422
                    }
423

  
424
                    /*
425
                     * if (fframe.getTypeScale()!=IFFrameUseFMap.AUTOMATICO) {
426
                     * fframeAux.setNewExtent(r);
427
                     * fframeAux.refresh();
428
                     * layout.getEFS().modifyFFrame((IFFrame)fframe,(IFFrame)
429
                     * fframeAux);
430
                     * ((IFFrame)fframeAux).getBoundingBox(layout.getAT());
431
                     * layout.updateFFrames();
432
                     * layout.setIsReSel(true);
433
                     * }else {
434
                     */
435
                    try {
436
                        fframe.setNewEnvelope(geomManager.createEnvelope(
437
                            r.getX(), r.getY(), r.getMaxX(), r.getMaxY(),
438
                            SUBTYPES.GEOM2D));
439
                    } catch (CreateEnvelopeException e) {
440
                        logger.error("Error creating the envelope", e);
441
                    }
442
                    fframe.refresh();
443
                    if (fframe.getLinked()) {
444
                        fframe.refreshOriginalExtent();
445
                    }
446
                    // /}
447
                    // Fin del else
448
                    // layout.repaint();
449
                }
450
            }
451
        }
452
    }
453

  
454
    /**
455
     * Realiza un zoom out a las vistas a?adidas al Layout y que est?n
456
     * seleccionadas
457
     * 
458
     * @param p2
459
     *            Punto central
460
     */
461
    public void setViewZoomOut(Point p2) {
462
        Point2D.Double pWorld;
463
        IFFrame[] fframes = layout.getLayoutContext().getFFrames();
464
        for (int i = 0; i < fframes.length; i++) {
465
            if (fframes[i] instanceof IFFrameUseFMap) {
466
                IFFrameUseFMap fframe = (IFFrameUseFMap) fframes[i];
467

  
468
                if (((IFFrame) fframe).getSelected() != IFFrame.NOSELECT) {
469

  
470
                    double nuevoX;
471
                    double nuevoY;
472
                    double cX;
473
                    double cY;
474
                    Point pScreen = new Point((int) p2.getX(), (int) p2.getY());
475
                    
476
                    Point2D vppo1 = FLayoutUtilities.screenCoordinatesToViewportImageCoordinates(
477
                        pScreen, fframes[i]);
478
                    
479
                    pWorld = FLayoutFunctions.toMapPoint(vppo1, fframe.getATMap());
480

  
481
                    cX = pWorld.getX();
482
                    cY = pWorld.getY();
483

  
484
                    double factor = 1 / MapContext.ZOOMOUTFACTOR;
485
                    Rectangle2D extent =
486
                        fframe.getMapContext().getViewPort().getExtent();
487
                    if (extent != null) {
488
                        nuevoX = cX - ((extent.getWidth() * factor) / 2.0);
489
                        nuevoY = cY - ((extent.getHeight() * factor) / 2.0);
490
                        double x = nuevoX;
491
                        double y = nuevoY;
492
                        double width = extent.getWidth() * factor;
493
                        double height = extent.getHeight() * factor;
494
                        try {
495
                            fframe.setNewEnvelope(geomManager.createEnvelope(x,
496
                                y, x + width, y + height, SUBTYPES.GEOM2D));
497
                        } catch (CreateEnvelopeException e) {
498
                            logger.error("Error creating the envelope", e);
499
                        }
500
                        fframe.refresh();
501
                        if (fframe.getLinked()) {
502
                            fframe.refreshOriginalExtent();
503
                        }
504
                    }
505
                }
506
            }
507
        }
508
    }
509

  
510
    /**
511
     * Modifica los puntos de control para generar el zoom del Layout
512
     * 
513
     * @param p1
514
     *            Punto inicial
515
     * @param p2
516
     *            Punto final
517
     */
518
    public void setPan(Point p1, Point p2) {
519
        IFFrame[] fframes = layout.getLayoutContext().getFFrames();
520

  
521
        for (int i = 0; i < fframes.length; i++) {
522
            if (fframes[i] instanceof IFFrameUseFMap) {
523
                IFFrameUseFMap fframe = (IFFrameUseFMap) fframes[i];
524
                AffineTransform at = fframe.getATMap();
525
                if (at != null) {
526
                    
527
                    Point2D vppo1 = FLayoutUtilities.screenCoordinatesToViewportImageCoordinates(
528
                        p1, fframes[i]);
529
                    Point2D vppo2 = FLayoutUtilities.screenCoordinatesToViewportImageCoordinates(
530
                        p2, fframes[i]);
531

  
532
                    Point2D px1 = FLayoutFunctions.toMapPoint(vppo1, at);
533
                    Point2D px2 = FLayoutFunctions.toMapPoint(vppo2, at);
534
                    fframe.movePoints(px1, px2);
535
                }
536
            }
537
        }
538
    }
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff