Revision 277
tags/org.gvsig.app.document.layout2.app-2.0.36/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.36</version> |
|
7 |
|
|
8 |
<name>Document: Layout document v2, parent artifact</name> |
|
9 |
<description>This plugin adds creation/management of layout (map) documents.</description> |
|
10 |
|
|
11 |
<parent> |
|
12 |
<groupId>org.gvsig</groupId> |
|
13 |
<artifactId>org.gvsig.desktop</artifactId> |
|
14 |
<version>2.0.57</version> |
|
15 |
</parent> |
|
16 |
|
|
17 |
<url>https://devel.gvsig.org/redmine/projects/gvsig-app-document-layout</url> |
|
18 |
|
|
19 |
<scm> |
|
20 |
<connection>scm:svn:https://devel.gvsig.org/svn/gvsig-app-document-layout/tags/org.gvsig.app.document.layout2.app-2.0.36</connection> |
|
21 |
<developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-app-document-layout/tags/org.gvsig.app.document.layout2.app-2.0.36</developerConnection> |
|
22 |
<url>https://devel.gvsig.org/redmine/projects/gvsig-app-document-layout/repository/show/tags/org.gvsig.app.document.layout2.app-2.0.36</url> |
|
23 |
</scm> |
|
24 |
<repositories> |
|
25 |
<repository> |
|
26 |
<id>gvsig-public-http-repository</id> |
|
27 |
<name>gvSIG maven public HTTP repository</name> |
|
28 |
<url>http://devel.gvsig.org/m2repo/j2se</url> |
|
29 |
<releases> |
|
30 |
<enabled>true</enabled> |
|
31 |
<updatePolicy>daily</updatePolicy> |
|
32 |
<checksumPolicy>warn</checksumPolicy> |
|
33 |
</releases> |
|
34 |
<snapshots> |
|
35 |
<enabled>true</enabled> |
|
36 |
<updatePolicy>daily</updatePolicy> |
|
37 |
<checksumPolicy>warn</checksumPolicy> |
|
38 |
</snapshots> |
|
39 |
</repository> |
|
40 |
</repositories> |
|
41 |
|
|
42 |
<build> |
|
43 |
<plugins> |
|
44 |
<plugin> |
|
45 |
<groupId>org.apache.maven.plugins</groupId> |
|
46 |
<artifactId>maven-release-plugin</artifactId> |
|
47 |
<configuration> |
|
48 |
<tagBase>https://devel.gvsig.org/svn/gvsig-app-document-layout/tags</tagBase> |
|
49 |
</configuration> |
|
50 |
</plugin> |
|
51 |
</plugins> |
|
52 |
</build> |
|
53 |
|
|
54 |
<modules> |
|
55 |
<module>org.gvsig.app.document.layout2.app.mainplugin</module> |
|
56 |
</modules> |
|
57 |
|
|
58 |
</project> |
tags/org.gvsig.app.document.layout2.app-2.0.36/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.36/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.36/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/math/intervals/IntervalUtils.java | ||
---|---|---|
1 |
package org.gvsig.math.intervals; |
|
2 |
|
|
3 |
public class IntervalUtils { |
|
4 |
|
|
5 |
/** |
|
6 |
* Calculates an nice round interval division. For instance, for |
|
7 |
* intervalLenght = 1100000 and numberOfDivisions=5, |
|
8 |
* the result would be 250000. |
|
9 |
* |
|
10 |
* @param intervalLength The full interval to be divided |
|
11 |
* @param numberOfDivisions The exact number of divisions to perform |
|
12 |
* @return A nice round interval division. The calculated result |
|
13 |
* ensures that the whole interval length is covered by the proposed |
|
14 |
* division, so it always fulfills the following formula: |
|
15 |
* <code>result*numberOfDivisions>=intervalLength</code> |
|
16 |
*/ |
|
17 |
public static double roundIntervalDivision(double intervalLength, int numberOfDivisions) { |
|
18 |
if (intervalLength<=0.0d || numberOfDivisions<=0) { |
|
19 |
return 0.0d; |
|
20 |
} |
|
21 |
|
|
22 |
double division = intervalLength/numberOfDivisions; |
|
23 |
if (division==0.0d) { |
|
24 |
return 0.0d; |
|
25 |
} |
|
26 |
double digitShift = Math.floor((Math.log10(division))); |
|
27 |
double scale = Math.pow(10, -digitShift); |
|
28 |
double firstSignificatDigit = Math.floor(scale*division); |
|
29 |
double result = firstSignificatDigit*Math.pow(10, digitShift); |
|
30 |
if (result*numberOfDivisions>=intervalLength) { |
|
31 |
return result; |
|
32 |
} |
|
33 |
else { |
|
34 |
result = (0.5+firstSignificatDigit)*Math.pow(10, digitShift); |
|
35 |
if (result*numberOfDivisions>=intervalLength) { |
|
36 |
return result; |
|
37 |
} |
|
38 |
} |
|
39 |
result = (1+firstSignificatDigit)*Math.pow(10, digitShift); |
|
40 |
return result; |
|
41 |
} |
|
42 |
} |
tags/org.gvsig.app.document.layout2.app-2.0.36/org.gvsig.app.document.layout2.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 java.awt.GridBagConstraints; |
|
25 |
import java.awt.Insets; |
|
26 |
|
|
27 |
import javax.swing.BorderFactory; |
|
28 |
import javax.swing.ImageIcon; |
|
29 |
import javax.swing.JCheckBox; |
|
30 |
import javax.swing.JComboBox; |
|
31 |
import javax.swing.JLabel; |
|
32 |
import javax.swing.JPanel; |
|
33 |
import javax.swing.JTextField; |
|
34 |
|
|
35 |
import org.gvsig.andami.IconThemeHelper; |
|
36 |
import org.gvsig.andami.PluginServices; |
|
37 |
import org.gvsig.andami.PluginsLocator; |
|
38 |
import org.gvsig.andami.preferences.AbstractPreferencePage; |
|
39 |
import org.gvsig.andami.preferences.StoreException; |
|
40 |
import org.gvsig.app.project.ProjectManager; |
|
41 |
import org.gvsig.app.project.documents.layout.Attributes; |
|
42 |
import org.gvsig.app.project.documents.layout.DefaultLayoutManager; |
|
43 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
44 |
import org.gvsig.gui.beans.swing.GridBagLayoutPanel; |
|
45 |
import org.gvsig.i18n.Messages; |
|
46 |
import org.gvsig.utils.XMLEntity; |
|
47 |
|
|
48 |
/** |
|
49 |
* Layout preference page where the user can establish default values for |
|
50 |
* <ol> |
|
51 |
* <li><b>grid horizontal gap</b></li> |
|
52 |
* <li><b>grid vertical gap</b></li> |
|
53 |
* <li><b>show or hide grid</b></li> |
|
54 |
* <li><b>adjust elements to grid</b></li> |
|
55 |
* <li><b>show or hide rules</b></li> |
|
56 |
* </ol> |
|
57 |
* |
|
58 |
* @author jaume dominguez faus - jaume.dominguez@iver.es |
|
59 |
* |
|
60 |
*/ |
|
61 |
public class LayoutPage extends AbstractPreferencePage { |
|
62 |
|
|
63 |
private static final long serialVersionUID = -8225970409668105935L; |
|
64 |
static String id = LayoutPage.class.getName();; |
|
65 |
private ImageIcon icon; |
|
66 |
private JCheckBox chkGridEnabled; |
|
67 |
private JCheckBox chkShowRules; |
|
68 |
private JCheckBox chkShowGrid; |
|
69 |
private JTextField txtVGap; |
|
70 |
private JTextField txtHGap; |
|
71 |
private JCheckBox chkShowInitialPageConfig; |
|
72 |
private JCheckBox chkShowLayoutTOC; |
|
73 |
private JComboBox cbHGapUnit; |
|
74 |
private JComboBox cbVGapUnit; |
|
75 |
|
|
76 |
private static DefaultLayoutManager layoutManager = null; |
|
77 |
|
|
78 |
/** |
|
79 |
* Builds preference page where the user can establish default values for |
|
80 |
* <ol> |
|
81 |
* <li><b>grid horizontal gap</b></li> |
|
82 |
* <li><b>grid vertical gap</b></li> |
|
83 |
* <li><b>show or hide grid</b></li> |
|
84 |
* <li><b>adjust elements to grid</b></li> |
|
85 |
* <li><b>show or hide rules</b></li> |
|
86 |
* </ol> |
|
87 |
*/ |
|
88 |
public LayoutPage() { |
|
89 |
super(); |
|
90 |
layoutManager = |
|
91 |
(DefaultLayoutManager) ProjectManager.getInstance() |
|
92 |
.getDocumentManager(DefaultLayoutManager.TYPENAME); |
|
93 |
|
|
94 |
icon = IconThemeHelper.getImageIcon("document-map-icon"); |
|
95 |
|
|
96 |
GridBagLayoutPanel gridRulerPanel = new GridBagLayoutPanel(); |
|
97 |
Insets topInsets = new Insets(10, 10, 0, 10); |
|
98 |
Insets insets = new Insets(8, 10, 0, 10); |
|
99 |
Insets lastInsets = new Insets(8, 10, 12, 10); |
|
100 |
gridRulerPanel.setBorder(BorderFactory.createTitledBorder(Messages.getText("Grid_and_ruler"))); |
|
101 |
|
|
102 |
// horizontal gap text field and units combo |
|
103 |
cbHGapUnit = new JComboBox(); |
|
104 |
String[] names = MapContext.getDistanceNames(); |
|
105 |
for (int i = 0; i < names.length; i++) { |
|
106 |
cbHGapUnit.addItem(PluginServices.getText(this, names[i])); |
|
107 |
} |
|
108 |
gridRulerPanel.addComponent(new JLabel(PluginServices.getText(this, "espaciado_horizontal")), |
|
109 |
txtHGap = new JTextField(5), cbHGapUnit, GridBagConstraints.NONE, insets); |
|
110 |
|
|
111 |
// vertical gap text field and units combo |
|
112 |
cbVGapUnit = new JComboBox(); |
|
113 |
for (int i = 0; i < names.length; i++) { |
|
114 |
cbVGapUnit.addItem(PluginServices.getText(this, names[i])); |
|
115 |
} |
|
116 |
gridRulerPanel.addComponent(new JLabel(PluginServices.getText(this, "espaciado_vertical")), |
|
117 |
txtVGap = new JTextField(5), cbVGapUnit, GridBagConstraints.NONE, insets); |
|
118 |
|
|
119 |
// show/hide show check |
|
120 |
gridRulerPanel.addComponent(chkShowGrid = |
|
121 |
new JCheckBox(PluginServices.getText(this, "visualizar_cuadricula")), insets); |
|
122 |
|
|
123 |
// enable/disable grid |
|
124 |
gridRulerPanel.addComponent(chkGridEnabled = |
|
125 |
new JCheckBox(PluginServices.getText(this, "malla_activada")), insets); |
|
126 |
|
|
127 |
// show/hide rules |
|
128 |
gridRulerPanel.addComponent(chkShowRules = |
|
129 |
new JCheckBox(PluginServices.getText(this, "activar_regla")), lastInsets); |
|
130 |
|
|
131 |
addComponent(gridRulerPanel, topInsets); |
|
132 |
|
|
133 |
GridBagLayoutPanel behaviourPanel = new GridBagLayoutPanel(); |
|
134 |
behaviourPanel.setBorder(BorderFactory.createTitledBorder(Messages.getText("User_interface"))); |
|
135 |
|
|
136 |
behaviourPanel.addComponent( |
|
137 |
chkShowInitialPageConfig = new JCheckBox(Messages.getText("Show_page_config_dialog_when_layout_document_is_created")), |
|
138 |
insets); |
|
139 |
|
|
140 |
behaviourPanel.addComponent( |
|
141 |
chkShowLayoutTOC = new JCheckBox(Messages.getText("Show_table_of_contents_TOC_for_Layout_views")), |
|
142 |
insets); |
|
143 |
|
|
144 |
addComponent(behaviourPanel, lastInsets); |
|
145 |
|
|
146 |
} |
|
147 |
|
|
148 |
public void storeValues() throws StoreException { |
|
149 |
double hGap, vGap; |
|
150 |
boolean gridEnabled, showRules, showGrid, showInitPageConfig, |
|
151 |
showLayoutToc; |
|
152 |
String hGapUnits, vGapUnits; |
|
153 |
try { |
|
154 |
hGap = Double.parseDouble(txtHGap.getText()); |
|
155 |
hGapUnits = MapContext.getDistanceAbbr()[cbHGapUnit.getSelectedIndex()]; |
|
156 |
vGap = Double.parseDouble(txtVGap.getText()); |
|
157 |
vGapUnits = MapContext.getDistanceAbbr()[cbVGapUnit.getSelectedIndex()]; |
|
158 |
gridEnabled = chkGridEnabled.isSelected(); |
|
159 |
showGrid = chkShowGrid.isSelected(); |
|
160 |
showRules = chkShowRules.isSelected(); |
|
161 |
showInitPageConfig = chkShowInitialPageConfig.isSelected(); |
|
162 |
showLayoutToc = chkShowLayoutTOC.isSelected(); |
|
163 |
} catch (Exception e) { |
|
164 |
throw new StoreException(PluginServices.getText(this, |
|
165 |
"invalid_value_for_gap")); |
|
166 |
} |
|
167 |
layoutManager.setDefaultShowGrid(showGrid); |
|
168 |
layoutManager.setDefaultAdjustToGrid(gridEnabled); |
|
169 |
layoutManager.setDefaultShowRulers(showRules); |
|
170 |
Attributes.setDefaultGridGap(hGap, vGap, hGapUnits, vGapUnits); |
|
171 |
PluginServices ps = PluginsLocator.getManager().getPlugin(this); |
|
172 |
XMLEntity xml = ps.getPersistentXML(); |
|
173 |
xml.putProperty(PreferenceKeys.DEFAULT_LAYOUT_GRID_HORIZONTAL_GAP_KEY_NAME, hGap); |
|
174 |
xml.putProperty(PreferenceKeys.DEFAULT_LAYOUT_GRID_VERTICAL_GAP_KEY_NAME, vGap); |
|
175 |
xml.putProperty(PreferenceKeys.DEFAULT_LAYOUT_GRID_HORIZONTAL_GAP_UNITS_KEY_NAME, hGapUnits); |
|
176 |
xml.putProperty(PreferenceKeys.DEFAULT_LAYOUT_GRID_VERTICAL_GAP_UNITS_KEY_NAME, vGapUnits); |
|
177 |
xml.putProperty(PreferenceKeys.DEFAULT_SHOW_LAYOUT_GRID_KEY_NAME, showGrid); |
|
178 |
xml.putProperty(PreferenceKeys.DEFAULT_ENABLE_LAYOUT_GRID_KEY_NAME, gridEnabled); |
|
179 |
xml.putProperty(PreferenceKeys.DEFAULT_SHOW_LAYOUT_RULERS_KEY_NAME, showRules); |
|
180 |
xml.putProperty(PreferenceKeys.DEFAULT_SHOW_INITIAL_CONFIG_DIALOG_KEY_NAME, showInitPageConfig); |
|
181 |
xml.putProperty(PreferenceKeys.DEFAULT_SHOW_LAYOUT_TOC_KEY_NAME, showLayoutToc); |
|
182 |
} |
|
183 |
|
|
184 |
public String getID() { |
|
185 |
return id; |
|
186 |
} |
|
187 |
|
|
188 |
public String getTitle() { |
|
189 |
return PluginServices.getText(this, "Mapa"); |
|
190 |
} |
|
191 |
|
|
192 |
public JPanel getPanel() { |
|
193 |
return this; |
|
194 |
} |
|
195 |
|
|
196 |
public void initializeValues() { |
|
197 |
PluginServices ps = PluginsLocator.getManager().getPlugin(this); |
|
198 |
XMLEntity xml = ps.getPersistentXML(); |
|
199 |
double hGap = PreferenceKeys.FACTORY_DEFAULT_HORIZONTAL_GAP; |
|
200 |
double vGap = PreferenceKeys.FACTORY_DEFAULT_VERTICAL_GAP; |
|
201 |
boolean showGrid = PreferenceKeys.FACTORY_DEFAULT_LAYOUT_GRID_SHOW; |
|
202 |
boolean gridEnabled = PreferenceKeys.FACTORY_DEFAULT_LAYOUT_GRID_ENABLE; |
|
203 |
boolean showRules = PreferenceKeys.FACTORY_DEFAULT_LAYOUT_ENABLE_RULERS; |
|
204 |
boolean showInitPageConfig = PreferenceKeys.FACTORY_DEFAULT_SHOW_INITIAL_CONFIG_DIALOG_FOR_LAYOUT; |
|
205 |
boolean showLayoutToc = PreferenceKeys.FACTORY_DEFAULT_SHOW_LAYOUT_TOC; |
|
206 |
// horizontal gap |
|
207 |
if (xml.contains(PreferenceKeys.DEFAULT_LAYOUT_GRID_HORIZONTAL_GAP_KEY_NAME)) { |
|
208 |
hGap = |
|
209 |
xml.getDoubleProperty(PreferenceKeys.DEFAULT_LAYOUT_GRID_HORIZONTAL_GAP_KEY_NAME); |
|
210 |
} |
|
211 |
txtHGap.setText(String.valueOf(hGap)); |
|
212 |
|
|
213 |
// vertical gap |
|
214 |
if (xml.contains(PreferenceKeys.DEFAULT_LAYOUT_GRID_VERTICAL_GAP_KEY_NAME)) { |
|
215 |
vGap = |
|
216 |
xml.getDoubleProperty(PreferenceKeys.DEFAULT_LAYOUT_GRID_VERTICAL_GAP_KEY_NAME); |
|
217 |
} |
|
218 |
txtVGap.setText(String.valueOf(vGap)); |
|
219 |
|
|
220 |
String hGapUnit = xml.contains(PreferenceKeys.DEFAULT_LAYOUT_GRID_HORIZONTAL_GAP_UNITS_KEY_NAME)? |
|
221 |
xml.getStringProperty(PreferenceKeys.DEFAULT_LAYOUT_GRID_HORIZONTAL_GAP_UNITS_KEY_NAME): |
|
222 |
PreferenceKeys.FACTORY_DEFAULT_HORIZONTAL_GAP_UNIT; |
|
223 |
cbHGapUnit.setSelectedIndex(Attributes.getDistanceAbbrPosition(hGapUnit)); |
|
224 |
|
|
225 |
String vGapUnit = xml.contains(PreferenceKeys.DEFAULT_LAYOUT_GRID_VERTICAL_GAP_UNITS_KEY_NAME)? |
|
226 |
xml.getStringProperty(PreferenceKeys.DEFAULT_LAYOUT_GRID_VERTICAL_GAP_UNITS_KEY_NAME): |
|
227 |
PreferenceKeys.FACTORY_DEFAULT_VERTICAL_GAP_UNIT; |
|
228 |
cbVGapUnit.setSelectedIndex(Attributes.getDistanceAbbrPosition(vGapUnit)); |
|
229 |
|
|
230 |
// show/hide grid check |
|
231 |
if (xml.contains(PreferenceKeys.DEFAULT_SHOW_LAYOUT_GRID_KEY_NAME)) { |
|
232 |
showGrid = |
|
233 |
xml.getBooleanProperty(PreferenceKeys.DEFAULT_SHOW_LAYOUT_GRID_KEY_NAME); |
|
234 |
} |
|
235 |
chkShowGrid.setSelected(showGrid); |
|
236 |
|
|
237 |
// enable/disable grid check |
|
238 |
if (xml.contains(PreferenceKeys.DEFAULT_ENABLE_LAYOUT_GRID_KEY_NAME)) { |
|
239 |
gridEnabled = |
|
240 |
xml.getBooleanProperty(PreferenceKeys.DEFAULT_ENABLE_LAYOUT_GRID_KEY_NAME); |
|
241 |
} |
|
242 |
chkGridEnabled.setSelected(gridEnabled); |
|
243 |
|
|
244 |
// enable/disable rules |
|
245 |
if (xml.contains(PreferenceKeys.DEFAULT_SHOW_LAYOUT_RULERS_KEY_NAME)) { |
|
246 |
showRules = |
|
247 |
xml.getBooleanProperty(PreferenceKeys.DEFAULT_SHOW_LAYOUT_RULERS_KEY_NAME); |
|
248 |
} |
|
249 |
chkShowRules.setSelected(showRules); |
|
250 |
|
|
251 |
if (xml.contains(PreferenceKeys.DEFAULT_SHOW_INITIAL_CONFIG_DIALOG_KEY_NAME)) { |
|
252 |
showInitPageConfig = xml.getBooleanProperty(PreferenceKeys.DEFAULT_SHOW_INITIAL_CONFIG_DIALOG_KEY_NAME); |
|
253 |
} |
|
254 |
chkShowInitialPageConfig.setSelected(showInitPageConfig); |
|
255 |
|
|
256 |
if (xml.contains(PreferenceKeys.DEFAULT_SHOW_LAYOUT_TOC_KEY_NAME)) { |
|
257 |
showLayoutToc = xml.getBooleanProperty(PreferenceKeys.DEFAULT_SHOW_LAYOUT_TOC_KEY_NAME); |
|
258 |
} |
|
259 |
chkShowLayoutTOC.setSelected(showLayoutToc); |
|
260 |
|
|
261 |
layoutManager.setDefaultShowGrid(showGrid); |
|
262 |
layoutManager.setDefaultAdjustToGrid(gridEnabled); |
|
263 |
layoutManager.setDefaultShowRulers(showRules); |
|
264 |
Attributes.setDefaultGridGap(hGap, vGap, hGapUnit, vGapUnit); |
|
265 |
} |
|
266 |
|
|
267 |
public void initializeDefaults() { |
|
268 |
txtHGap.setText(String.valueOf(PreferenceKeys.FACTORY_DEFAULT_HORIZONTAL_GAP)); |
|
269 |
txtVGap.setText(String.valueOf(PreferenceKeys.FACTORY_DEFAULT_VERTICAL_GAP)); |
|
270 |
cbHGapUnit.setSelectedIndex(Attributes.getDistanceAbbrPosition(PreferenceKeys.FACTORY_DEFAULT_HORIZONTAL_GAP_UNIT)); |
|
271 |
cbVGapUnit.setSelectedIndex(Attributes.getDistanceAbbrPosition(PreferenceKeys.FACTORY_DEFAULT_VERTICAL_GAP_UNIT)); |
|
272 |
chkShowGrid.setSelected(PreferenceKeys.FACTORY_DEFAULT_LAYOUT_GRID_SHOW); |
|
273 |
chkGridEnabled.setSelected(PreferenceKeys.FACTORY_DEFAULT_LAYOUT_GRID_ENABLE); |
|
274 |
chkShowRules.setSelected(PreferenceKeys.FACTORY_DEFAULT_LAYOUT_ENABLE_RULERS); |
|
275 |
chkShowInitialPageConfig.setSelected(PreferenceKeys.FACTORY_DEFAULT_SHOW_INITIAL_CONFIG_DIALOG_FOR_LAYOUT); |
|
276 |
} |
|
277 |
|
|
278 |
public ImageIcon getIcon() { |
|
279 |
return icon; |
|
280 |
} |
|
281 |
|
|
282 |
public boolean isValueChanged() { |
|
283 |
return super.hasChanged(); |
|
284 |
} |
|
285 |
|
|
286 |
public void setChangesApplied() { |
|
287 |
setChanged(false); |
|
288 |
} |
|
289 |
} |
tags/org.gvsig.app.document.layout2.app-2.0.36/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/gui/preferencespage/PreferenceKeys.java | ||
---|---|---|
1 |
package org.gvsig.app.gui.preferencespage; |
|
2 |
|
|
3 |
/** |
|
4 |
* The purpose of this interface is to define the keys used for the |
|
5 |
* persistence of this plugin in order to make these keys available |
|
6 |
* on library level, instead of defining them within the |
|
7 |
* preference page (which has UI dependences). |
|
8 |
* |
|
9 |
* @author Cesar Martinez Izquierdo <cesar.izq@gmail.com> |
|
10 |
* |
|
11 |
*/ |
|
12 |
public interface PreferenceKeys { |
|
13 |
String DEFAULT_SHOW_LAYOUT_GRID_KEY_NAME = "DefaultShowLayoutGrid"; |
|
14 |
String DEFAULT_ENABLE_LAYOUT_GRID_KEY_NAME = "DefaultEnableLayoutGrid"; |
|
15 |
String DEFAULT_SHOW_LAYOUT_RULERS_KEY_NAME = "DefaultShowLayoutRules"; |
|
16 |
String DEFAULT_LAYOUT_GRID_VERTICAL_GAP_KEY_NAME = "DefaultGridVerticalGap"; |
|
17 |
String DEFAULT_LAYOUT_GRID_HORIZONTAL_GAP_KEY_NAME = "DefaultGridHorizontalGap"; |
|
18 |
String DEFAULT_LAYOUT_GRID_VERTICAL_GAP_UNITS_KEY_NAME = "DefaultGridVerticalGapUnits"; |
|
19 |
String DEFAULT_LAYOUT_GRID_HORIZONTAL_GAP_UNITS_KEY_NAME = "DefaultGridHorizontalGapUnits"; |
|
20 |
String DEFAULT_SHOW_INITIAL_CONFIG_DIALOG_KEY_NAME = "DefaulShowInitialPageConfigLayout"; |
|
21 |
String DEFAULT_SHOW_LAYOUT_TOC_KEY_NAME = "DefaultShowLayoutToc"; |
|
22 |
boolean FACTORY_DEFAULT_LAYOUT_ENABLE_RULERS = true; |
|
23 |
boolean FACTORY_DEFAULT_LAYOUT_GRID_SHOW = true; |
|
24 |
double FACTORY_DEFAULT_VERTICAL_GAP = 1.0d; |
|
25 |
double FACTORY_DEFAULT_HORIZONTAL_GAP = 1.0d; |
|
26 |
String FACTORY_DEFAULT_VERTICAL_GAP_UNIT = "cm"; |
|
27 |
String FACTORY_DEFAULT_HORIZONTAL_GAP_UNIT = "cm"; |
|
28 |
boolean FACTORY_DEFAULT_LAYOUT_GRID_ENABLE = false; |
|
29 |
boolean FACTORY_DEFAULT_SHOW_INITIAL_CONFIG_DIALOG_FOR_LAYOUT = true; |
|
30 |
boolean FACTORY_DEFAULT_SHOW_LAYOUT_TOC = true; |
|
31 |
|
|
32 |
} |
tags/org.gvsig.app.document.layout2.app-2.0.36/org.gvsig.app.document.layout2.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 |
} |
|
0 | 141 |
tags/org.gvsig.app.document.layout2.app-2.0.36/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.gui.WindowLayout; |
|
46 |
import org.gvsig.app.project.documents.layout.contextmenu.gui.AbstractLayoutContextMenuAction; |
|
47 |
import org.gvsig.app.project.documents.layout.fframes.FrameFactory; |
|
48 |
import org.gvsig.app.project.documents.layout.fframes.IFFrame; |
|
49 |
import org.gvsig.app.project.documents.layout.fframes.gui.dialogs.IFFrameDialog; |
|
50 |
import org.gvsig.app.project.documents.layout.gui.DefaultLayoutPanel; |
|
51 |
import org.gvsig.app.project.documents.layout.gui.LayoutPanel; |
|
52 |
import org.gvsig.app.project.documents.layout.gui.MapProperties; |
|
53 |
import org.gvsig.app.project.documents.layout.gui.dialogs.FConfigLayoutDialog; |
|
54 |
import org.gvsig.app.project.documents.view.IContextMenuAction; |
|
55 |
import org.gvsig.tools.ToolsLocator; |
|
56 |
import org.gvsig.tools.dynobject.DynStruct; |
|
57 |
import org.gvsig.tools.extensionpoint.ExtensionPoint; |
|
58 |
import org.gvsig.tools.extensionpoint.ExtensionPoint.Extension; |
|
59 |
import org.gvsig.tools.extensionpoint.ExtensionPointManager; |
|
60 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
61 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
62 |
import org.gvsig.utils.XMLEntity; |
|
63 |
import org.slf4j.Logger; |
|
64 |
import org.slf4j.LoggerFactory; |
|
65 |
|
|
66 |
/** |
|
67 |
* Factory of maps. |
|
68 |
* |
|
69 |
* @author Vicente Caballero Navarro |
|
70 |
*/ |
|
71 |
public class DefaultLayoutManager extends AbstractDocumentManager implements |
|
72 |
LayoutManager { |
|
73 |
static final Logger LOG = LoggerFactory |
|
74 |
.getLogger(DefaultLayoutManager.class); |
|
75 |
|
|
76 |
static final String KEY_LAYOUT_FFRAMEDIALOG = |
|
77 |
"app.project.documents.layout.fframes.gui"; |
|
78 |
static final String KEY_LAYOUT_FFRAME = |
|
79 |
"app.project.documents.layout.fframes"; |
|
80 |
|
|
81 |
public static final String PERSISTENCE_LAYOUT_DOCUMENT_DEFINITION_NAME = |
|
82 |
"LayoutDocument"; |
|
83 |
|
|
84 |
private static final String LAYOUT_CONTEXT_MENUS = "Layout_ContextMenus"; |
|
85 |
|
|
86 |
ExtensionPointManager extensionPoints = ToolsLocator |
|
87 |
.getExtensionPointManager(); |
|
88 |
|
|
89 |
private Boolean defaultShowGrid = null; |
|
90 |
private Boolean defaultAdjustToGrid = null; |
|
91 |
private Boolean defaultShowRulers = null; |
|
92 |
|
|
93 |
private DynStruct persistenceDefinition; |
|
94 |
|
|
95 |
/** |
|
96 |
* Returns image of button. |
|
97 |
* |
|
98 |
* @return Image button. |
|
99 |
*/ |
|
100 |
public ImageIcon getIcon() { |
|
101 |
return ToolsSwingLocator.getIconThemeManager().getCurrent().get("document-map-icon"); |
|
102 |
} |
|
103 |
|
|
104 |
/** |
|
105 |
* Returns image of selected button. |
|
106 |
* |
|
107 |
* @return Image button. |
|
108 |
*/ |
|
109 |
public ImageIcon getIconSelected() { |
|
110 |
return ToolsSwingLocator.getIconThemeManager().getCurrent().get("document-map-icon-sel"); |
|
111 |
} |
|
112 |
|
|
113 |
/** |
|
114 |
* Returns the name of registration in the point of extension. |
|
115 |
* |
|
116 |
* @return Name of registration |
|
117 |
*/ |
|
118 |
public String getTypeName() { |
|
119 |
return TYPENAME; |
|
120 |
} |
|
121 |
|
|
122 |
/** |
|
123 |
* Returns the name of ProjectDocument. |
|
124 |
* |
|
125 |
* @return Name of ProjectDocument. |
|
126 |
*/ |
|
127 |
public String getTitle() { |
|
128 |
return PluginServices.getText(this, "Mapa"); |
|
129 |
} |
|
130 |
|
|
131 |
public AbstractDocument createDocument() { |
|
132 |
return new DefaultLayoutDocument(this); |
|
133 |
} |
|
134 |
|
|
135 |
public Class getMainWindowClass() { |
|
136 |
return DefaultLayoutPanel.class; |
|
137 |
} |
|
138 |
|
|
139 |
public IWindow getMainWindow(Document doc, WindowLayout layout) { |
|
140 |
LayoutPanel layoutPanel; |
|
141 |
layoutPanel = |
|
142 |
(LayoutPanel) PluginServices.getMDIManager().getSingletonWindow( |
|
143 |
getMainWindowClass(), doc); |
|
144 |
if (layoutPanel != null) { |
|
145 |
// The layout window document is already created, return it. |
|
146 |
return layoutPanel; |
|
147 |
} |
|
148 |
|
|
149 |
layoutPanel = (LayoutPanel) this.createDocumentWindow(doc); |
|
150 |
if (layout != null) { |
|
151 |
layoutPanel.setWindowLayout(layout); |
|
152 |
} |
|
153 |
layoutPanel.setLayoutManager(this); |
|
154 |
layoutPanel.getLayoutControl().fullRect(); |
|
155 |
layoutPanel.getWindowInfo().setTitle( |
|
156 |
PluginServices.getText(this, "Mapa") + " : " |
|
157 |
+ layoutPanel.getName()); |
|
158 |
((AbstractDocument) doc).raiseEventCreateWindow(layoutPanel); |
|
159 |
return layoutPanel; |
|
160 |
} |
|
161 |
|
|
162 |
public IFFrameDialog createFFrameDialog(IFFrame fframe, |
|
163 |
LayoutPanel layoutPanel, AffineTransform affineTransform) { |
|
164 |
ExtensionPoint ep = extensionPoints.add(KEY_LAYOUT_FFRAMEDIALOG); |
|
165 |
|
|
166 |
try { |
|
167 |
Object[] args = new Object[2]; |
|
168 |
args[0] = layoutPanel; |
|
169 |
args[1] = fframe; |
|
170 |
Object obj = ep.create(fframe.getName(), args); |
|
171 |
if (obj != null) { |
|
172 |
IFFrameDialog fframedialog = (IFFrameDialog) obj; |
|
173 |
fframedialog.setRectangle(fframe |
|
174 |
.getBoundingBox(affineTransform)); |
|
175 |
return fframedialog; |
|
176 |
} |
|
177 |
} catch (Exception e) { |
|
178 |
LOG.error("Error creating a FFrameDialog", e); |
|
179 |
} |
|
180 |
return null; |
|
181 |
} |
|
182 |
|
|
183 |
public IFFrameDialog createFFrameDialog(IFFrame fframe, |
|
184 |
LayoutPanel layoutPanel) { |
|
185 |
return createFFrameDialog(fframe, layoutPanel, layoutPanel |
|
186 |
.getLayoutControl().getAT()); |
|
187 |
} |
|
188 |
|
|
189 |
public void registerFrameFactory(FrameFactory frameFactory, String alias) { |
|
190 |
ExtensionPoint ep = |
|
191 |
ToolsLocator.getExtensionPointManager().add(KEY_LAYOUT_FFRAME); |
|
192 |
ep.append(frameFactory.getRegisterName(), "", frameFactory); |
|
193 |
if (alias != null) { |
|
194 |
ep.addAlias(frameFactory.getRegisterName(), alias); |
|
195 |
} |
|
196 |
} |
|
197 |
|
|
198 |
public void registerFrameFactory(FrameFactory frameFactory) { |
|
199 |
registerFrameFactory(frameFactory, null); |
|
200 |
} |
|
201 |
|
|
202 |
@SuppressWarnings("unchecked") |
|
203 |
public IFFrame createFrame(String frameName) { |
|
204 |
|
|
205 |
Iterator<Extension> iterator = |
|
206 |
ToolsLocator.getExtensionPointManager().get(KEY_LAYOUT_FFRAME) |
|
207 |
.iterator(); |
|
208 |
while (iterator.hasNext()) { |
|
209 |
try { |
|
210 |
FrameFactory frameFactory = |
|
211 |
(FrameFactory) iterator.next().create(); |
|
212 |
if (frameFactory.getRegisterName().equals(frameName)) { |
|
213 |
IFFrame frame = frameFactory.createFrame(); |
|
214 |
if (frame == null) { |
|
215 |
return null; |
|
216 |
} |
|
217 |
frame.setFrameFactory(frameFactory); |
|
218 |
return frame; |
|
219 |
} |
|
220 |
} catch (Exception e) { |
|
221 |
NotificationManager.addError(e); |
|
222 |
} |
|
223 |
} |
|
224 |
return null; |
|
225 |
} |
|
226 |
|
|
227 |
@SuppressWarnings("unchecked") |
|
228 |
public void registerFFrameDialog(String name, Class clazz) { |
|
229 |
if (!IFFrameDialog.class.isAssignableFrom(clazz)) { |
|
230 |
throw new IllegalArgumentException(clazz.getName() |
|
231 |
+ " must implement the IFFrameDialog interface"); |
|
232 |
} |
|
233 |
ExtensionPoint extensionPoint = |
|
234 |
extensionPoints.add(KEY_LAYOUT_FFRAMEDIALOG, ""); |
|
235 |
extensionPoint.append(name, name, clazz); |
|
236 |
} |
|
237 |
|
|
238 |
public IWindow getPropertiesWindow(Document doc) { |
|
239 |
return new MapProperties((LayoutDocument) doc); |
|
240 |
} |
|
241 |
|
|
242 |
/** |
|
243 |
* Registers in the points of extension the Factory with alias. |
|
244 |
* |
|
245 |
*/ |
|
246 |
public static void register() { |
|
247 |
DefaultLayoutManager factory = new DefaultLayoutManager(); |
|
248 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
|
249 |
manager.registerFactory(factory); |
|
250 |
|
|
251 |
ProjectManager.getInstance().registerDocumentFactory(factory); |
|
252 |
|
|
253 |
if (factory.persistenceDefinition == null) { |
|
254 |
factory.persistenceDefinition = |
|
255 |
manager.addDefinition(LayoutDocument.class, |
|
256 |
PERSISTENCE_LAYOUT_DOCUMENT_DEFINITION_NAME, |
|
257 |
"Layout document Persistence definition", null, null); |
|
258 |
factory.persistenceDefinition.extend(manager |
|
259 |
.getDefinition(AbstractDocument.PERSISTENCE_DEFINITION_NAME)); |
|
260 |
|
|
261 |
factory.persistenceDefinition |
|
262 |
.addDynFieldObject(DefaultLayoutDocument.LAYOUT_CONTEXT_OBJECT) |
|
263 |
.setClassOfValue(LayoutContext.class).setMandatory(false); |
|
264 |
|
|
265 |
DefaultLayoutPanel.registerPersistent(); |
|
266 |
DefaultLayoutContext.registerPersistent(); |
|
267 |
} |
|
268 |
} |
|
269 |
|
|
270 |
public int getPriority() { |
|
271 |
return 2; |
|
272 |
} |
|
273 |
|
|
274 |
/** |
|
275 |
* Sets whether the grid should be shown. |
|
276 |
* |
|
277 |
* @param showGrid |
|
278 |
*/ |
|
279 |
public void setDefaultShowGrid(boolean showGrid) { |
|
280 |
defaultShowGrid = new Boolean(showGrid); |
|
281 |
} |
|
282 |
|
|
283 |
/** |
|
284 |
* Sets whether the snapping to grid should be enabled or not |
|
285 |
* |
|
286 |
* @param gridEnable |
|
287 |
*/ |
|
288 |
public void setDefaultAdjustToGrid(boolean gridEnabled) { |
|
289 |
defaultAdjustToGrid = new Boolean(gridEnabled); |
|
290 |
} |
|
291 |
|
|
292 |
/** |
|
293 |
* Sets whether the ruler should be shown or not |
|
294 |
* |
|
295 |
* @param showRuler |
|
296 |
*/ |
|
297 |
public void setDefaultShowRulers(boolean showRules) { |
|
298 |
defaultShowRulers = new Boolean(showRules); |
|
299 |
} |
|
300 |
|
|
301 |
/** |
|
302 |
* Returns if the grid should be shown. |
|
303 |
* |
|
304 |
* @return True if the grid should be shown. |
|
305 |
*/ |
|
306 |
public boolean getDefaultShowGrid() { |
|
307 |
if (defaultShowGrid == null) { |
|
308 |
XMLEntity xml = PluginsLocator.getManager().getPlugin(this).getPersistentXML(); |
|
309 |
if (xml.contains(PreferenceKeys.DEFAULT_SHOW_LAYOUT_GRID_KEY_NAME)) { |
|
310 |
defaultShowGrid = |
|
311 |
new Boolean(xml.getBooleanProperty(PreferenceKeys.DEFAULT_SHOW_LAYOUT_GRID_KEY_NAME)); |
|
312 |
} else { |
|
313 |
defaultShowGrid = new Boolean(PreferenceKeys.FACTORY_DEFAULT_LAYOUT_GRID_SHOW); |
|
314 |
} |
|
315 |
} |
|
316 |
return defaultShowGrid.booleanValue(); |
|
317 |
} |
|
318 |
|
|
319 |
/** |
|
320 |
* Returns if the adjust to grid should be active. |
|
321 |
* |
|
322 |
* @return True if the adjust to grid should be active. |
|
323 |
*/ |
|
324 |
public boolean getDefaultAdjustToGrid() { |
|
325 |
if (defaultAdjustToGrid == null) { |
|
326 |
XMLEntity xml = PluginsLocator.getManager().getPlugin(this).getPersistentXML(); |
|
327 |
if (xml.contains(PreferenceKeys.DEFAULT_ENABLE_LAYOUT_GRID_KEY_NAME)) { |
|
328 |
defaultAdjustToGrid = |
|
329 |
new Boolean( |
|
330 |
xml.getBooleanProperty(PreferenceKeys.DEFAULT_ENABLE_LAYOUT_GRID_KEY_NAME)); |
|
331 |
} else { |
|
332 |
defaultAdjustToGrid = new Boolean(PreferenceKeys.FACTORY_DEFAULT_LAYOUT_GRID_ENABLE); |
|
333 |
} |
|
334 |
} |
|
335 |
return defaultAdjustToGrid.booleanValue(); |
|
336 |
} |
|
337 |
|
|
338 |
/** |
|
339 |
* Returns if the ruler should be shown. |
|
340 |
* |
|
341 |
* @return True if the ruler should be shown. |
|
342 |
*/ |
|
343 |
public boolean getDefaultShowRulers() { |
|
344 |
if (defaultShowRulers == null) { |
|
345 |
XMLEntity xml = PluginsLocator.getManager().getPlugin(this).getPersistentXML(); |
|
346 |
if (xml.contains(PreferenceKeys.DEFAULT_SHOW_LAYOUT_RULERS_KEY_NAME)) { |
|
347 |
defaultShowRulers = |
|
348 |
new Boolean( |
|
349 |
xml.getBooleanProperty(PreferenceKeys.DEFAULT_SHOW_LAYOUT_RULERS_KEY_NAME)); |
|
350 |
} else { |
|
351 |
defaultShowRulers = new Boolean(PreferenceKeys.FACTORY_DEFAULT_LAYOUT_ENABLE_RULERS); |
|
352 |
} |
|
353 |
} |
|
354 |
return defaultShowRulers.booleanValue(); |
|
355 |
} |
|
356 |
|
|
357 |
public boolean getDefaultShowInitialPageConfigDialog() { |
|
358 |
XMLEntity xml = PluginsLocator.getManager().getPlugin(this).getPersistentXML(); |
|
359 |
boolean value; |
|
360 |
if (xml.contains(PreferenceKeys.DEFAULT_SHOW_INITIAL_CONFIG_DIALOG_KEY_NAME)) { |
|
361 |
value = xml.getBooleanProperty(PreferenceKeys.DEFAULT_SHOW_INITIAL_CONFIG_DIALOG_KEY_NAME); |
|
362 |
} else { |
|
363 |
value = PreferenceKeys.FACTORY_DEFAULT_SHOW_INITIAL_CONFIG_DIALOG_FOR_LAYOUT; |
|
364 |
} |
|
365 |
return value; |
|
366 |
} |
|
367 |
|
|
368 |
public DynStruct getDefinition(String className) { |
|
369 |
|
|
370 |
if (this.persistenceDefinition.getName().equalsIgnoreCase(className)) { |
|
371 |
return this.persistenceDefinition; |
|
372 |
} |
|
373 |
if (this.persistenceDefinition.getFullName() |
|
374 |
.equalsIgnoreCase(className)) { |
|
375 |
return this.persistenceDefinition; |
|
376 |
} |
|
377 |
if (this.getDocumentClass().getName().equals(className)) { |
|
378 |
return this.persistenceDefinition; |
|
379 |
} |
|
380 |
return null; |
|
381 |
} |
|
382 |
|
|
383 |
@SuppressWarnings("unchecked") |
|
384 |
protected Class getDocumentClass() { |
|
385 |
return DefaultLayoutDocument.class; |
|
386 |
} |
|
387 |
|
|
388 |
public boolean manages(Object object) { |
|
389 |
return object instanceof LayoutDocument; |
|
390 |
} |
|
391 |
|
|
392 |
public void registerLayoutMenuAction(String name, |
|
393 |
Class<? extends IContextMenuAction> clazz) { |
|
394 |
ExtensionPoint extensionPoint = |
|
395 |
ToolsLocator.getExtensionPointManager().add(LAYOUT_CONTEXT_MENUS); |
|
396 |
extensionPoint.append(name, "", clazz); |
|
397 |
} |
|
398 |
|
|
399 |
public IContextMenuAction[] createLayoutMenuActions(LayoutPanel layoutPanel) { |
|
400 |
List<IContextMenuAction> actionArrayList = |
|
401 |
new ArrayList<IContextMenuAction>(); |
|
402 |
@SuppressWarnings("unchecked") |
|
403 |
Iterator<ExtensionPoint.Extension> iter = |
|
404 |
ToolsLocator.getExtensionPointManager().get(LAYOUT_CONTEXT_MENUS).iterator(); |
|
405 |
AbstractLayoutContextMenuAction action; |
|
406 |
while (iter.hasNext()) { |
|
407 |
action = null; |
|
408 |
try { |
|
409 |
action = (AbstractLayoutContextMenuAction) iter.next().create(); |
|
410 |
} catch (InstantiationException e) { |
|
411 |
LOG.error("Error creating the context menu", e); |
|
412 |
} catch (IllegalAccessException e) { |
|
413 |
LOG.error("Error creating the context menu", e); |
|
414 |
} |
|
415 |
if (action != null) { |
|
416 |
action.setLayout(layoutPanel); |
|
417 |
if (action.isVisible(null, layoutPanel.getLayoutContext().getSelectedFFrames())) { |
|
418 |
actionArrayList.add(action); |
|
419 |
} |
|
420 |
} |
|
421 |
} |
|
422 |
IContextMenuAction[] result = |
|
423 |
(IContextMenuAction[]) Array.newInstance(IContextMenuAction.class, |
|
424 |
actionArrayList.size()); |
|
425 |
System.arraycopy(actionArrayList.toArray(), 0, result, 0, |
|
426 |
actionArrayList.size()); |
|
427 |
Arrays.sort(result, new CompareAction()); |
|
428 |
return result; |
|
429 |
} |
|
430 |
|
|
431 |
private class CompareAction implements Comparator<IContextMenuAction> { |
|
432 |
|
|
433 |
public int compare(IContextMenuAction o1, IContextMenuAction o2) { |
|
434 |
NumberFormat formater = NumberFormat.getInstance(); |
|
435 |
formater.setMinimumIntegerDigits(3); |
|
436 |
String key1 = |
|
437 |
"" + formater.format(o1.getGroupOrder()) + o1.getGroup() |
|
438 |
+ formater.format(o1.getOrder()); |
|
439 |
String key2 = |
|
440 |
"" + formater.format(o2.getGroupOrder()) + o2.getGroup() |
|
441 |
+ formater.format(o2.getOrder()); |
|
442 |
return key1.compareTo(key2); |
|
443 |
} |
|
444 |
} |
|
445 |
} |
tags/org.gvsig.app.document.layout2.app-2.0.36/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/LayoutControl.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.Image; |
|
25 |
import java.awt.Point; |
|
26 |
import java.awt.Rectangle; |
|
27 |
import java.awt.geom.AffineTransform; |
|
28 |
import java.awt.geom.Rectangle2D; |
|
29 |
import java.awt.image.BufferedImage; |
|
30 |
|
|
31 |
import javax.swing.JComponent; |
|
32 |
|
|
33 |
import org.gvsig.app.project.documents.layout.geometryadapters.GeometryAdapter; |
|
34 |
import org.gvsig.app.project.documents.layout.gui.LayoutPanel; |
|
35 |
import org.gvsig.app.project.documents.layout.tools.behavior.LayoutBehavior; |
|
36 |
import org.gvsig.fmap.dal.exception.ReadException; |
|
37 |
import org.gvsig.tools.observer.Observer; |
|
38 |
|
|
39 |
/** |
|
40 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodrá</a> |
|
41 |
*/ |
|
42 |
public interface LayoutControl extends Observer { |
|
43 |
|
|
44 |
/** |
|
45 |
* Returns the rectangle that represents the sheet. |
|
46 |
* In pixels. |
|
47 |
* |
|
48 |
* @return Rectangle2D.Double Rectangle that represents the sheet. |
|
49 |
*/ |
|
50 |
public Rectangle2D.Double getRect(); |
|
51 |
|
|
52 |
/** |
|
53 |
* Returns the name of the current selected tool on this Layout |
|
54 |
* |
|
55 |
* @return A tool name. |
|
56 |
*/ |
|
57 |
public String getCurrentTool(); |
|
58 |
|
|
59 |
/** |
|
60 |
* Add a new Layout tool. |
|
61 |
* |
|
62 |
* @param name |
|
63 |
* Name of tool. |
|
64 |
* @param tool |
|
65 |
* LayoutBehavior |
|
66 |
*/ |
|
67 |
public void addLayoutTool(String name, LayoutBehavior tool); |
|
68 |
|
|
69 |
/** |
|
70 |
* Inserts the LayoutContext. |
|
71 |
* |
|
72 |
* @param lc |
|
73 |
* LayoutContext. |
|
74 |
*/ |
|
75 |
public void setLayoutContext(LayoutContext lc); |
|
76 |
|
|
77 |
/** |
|
78 |
* Returns the image with the ruler. |
|
79 |
* |
|
80 |
* @return Ruler image. |
|
81 |
*/ |
|
82 |
public BufferedImage getImgRuler(); |
|
83 |
|
|
84 |
/** |
|
85 |
* It obtains the rect that is adjusted to the size of the window, |
|
86 |
* to see the full extent of layout. |
|
87 |
*/ |
|
88 |
public void fullRect(); |
|
89 |
|
|
90 |
/** |
|
91 |
* Inserts the rectangle that represents the sheet. |
|
92 |
* In pixels. |
|
93 |
* |
|
94 |
*/ |
|
95 |
public void setRect(Rectangle2D r); |
|
96 |
|
|
97 |
/** |
|
98 |
* Returns the current image of Layout. |
|
99 |
* |
|
100 |
* @return Current image of Layout. |
|
101 |
*/ |
|
102 |
public BufferedImage getImage(); |
|
103 |
|
|
104 |
/** |
|
105 |
* Changes the pointer of the mouse by the image of parameter. |
|
106 |
* |
|
107 |
* @param image |
|
108 |
* Image |
|
109 |
*/ |
|
110 |
public void setMapCursor(Image image); |
|
111 |
|
|
112 |
/** |
|
113 |
* It establishes as selected to the tool from its name of identification. |
|
114 |
* |
|
115 |
* @param toolName |
|
116 |
* Name of identification tool. |
|
117 |
*/ |
|
118 |
public void setTool(String toolName); |
|
119 |
|
|
120 |
/** |
|
121 |
* Changes the currently selected tool to the default tool |
|
122 |
*/ |
|
123 |
public void setDefaultTool(); |
|
124 |
|
|
125 |
/** |
|
126 |
* Start the vertex edition of graphics. |
|
127 |
* |
|
128 |
*/ |
|
129 |
public void startEdit(); |
|
130 |
|
|
131 |
/** |
|
132 |
* Stop the vertex edition of graphics. |
|
133 |
* |
|
134 |
*/ |
|
135 |
public void stopEdit(); |
|
136 |
|
|
137 |
/** |
|
138 |
* It returns the point that represents the northwest corner of the Layout. |
|
139 |
* |
|
140 |
* @return Point. |
|
141 |
*/ |
|
142 |
public Point getRectOrigin(); |
|
143 |
|
|
144 |
/** |
|
145 |
* Returns the object to draw the Layout. |
|
146 |
* |
|
147 |
* @return FLayoutDraw. |
|
148 |
*/ |
|
149 |
public FLayoutDraw getLayoutDraw(); |
|
150 |
|
|
151 |
/** |
|
152 |
* Returns the current Layout tool. |
|
153 |
* |
|
154 |
* @return LayoutBehavior Current Layout Tool. |
|
155 |
*/ |
|
156 |
public LayoutBehavior getCurrentLayoutTool(); |
|
157 |
|
|
158 |
/** |
|
159 |
* It returns the first click point of mouse. |
|
160 |
* |
|
161 |
* @return Point. |
|
162 |
*/ |
|
163 |
public Point getFirstPoint(); |
|
164 |
|
|
165 |
/** |
|
166 |
* Returns the previous click of mouse. |
|
167 |
* |
|
168 |
* @return Point. |
|
169 |
*/ |
|
170 |
public Point getPointAnt(); |
|
171 |
|
|
172 |
/** |
|
173 |
* Returns the last click point of mouse. |
|
174 |
* |
|
175 |
* @return Point. |
|
176 |
*/ |
|
177 |
public Point getLastPoint(); |
|
178 |
|
|
179 |
/** |
|
180 |
* Inserts the first click point of mouse. |
|
181 |
* |
|
182 |
* @param p |
|
183 |
* Point. |
|
184 |
*/ |
|
185 |
public void setFirstPoint(); |
|
186 |
|
|
187 |
/** |
|
188 |
* Inserts the previous click point of mouse. |
|
189 |
* |
|
190 |
* @param p |
|
191 |
* Point. |
|
192 |
*/ |
|
193 |
public void setPointAnt(); |
|
194 |
|
|
195 |
/** |
|
196 |
* Inserts the last click point of mouse. |
|
197 |
* |
|
198 |
* @param p |
|
199 |
* Point. |
|
200 |
*/ |
|
201 |
public void setLastPoint(); |
|
202 |
|
|
203 |
/** |
|
204 |
* Insert the position point and calculate the new position if the grid is |
|
205 |
* actived. |
|
206 |
* |
|
207 |
* @param point2 |
|
208 |
* Position. |
|
209 |
*/ |
|
210 |
public void setPosition(Point point2); |
|
211 |
|
|
212 |
/** |
|
213 |
* Returns the position adjusted point. |
|
214 |
* |
|
215 |
* @return |
|
216 |
*/ |
|
217 |
public Point getPosition(); |
|
218 |
|
|
219 |
/** |
|
220 |
* Returns the AffineTransform that is applying in the Layout. |
|
221 |
* |
|
222 |
* @return AffineTransform |
|
223 |
*/ |
|
224 |
public AffineTransform getAT(); |
|
225 |
|
|
226 |
/** |
|
227 |
* It returns the current GeometryAdapter. |
|
228 |
* |
|
229 |
* @return Current GeometryAdapter. |
|
230 |
*/ |
|
231 |
public GeometryAdapter getGeometryAdapter(); |
|
232 |
|
|
233 |
/** |
|
234 |
* Remove last point of geometryAdapter. |
|
235 |
* |
|
236 |
*/ |
|
237 |
public void delLastPoint(); |
|
238 |
|
|
239 |
/** |
|
240 |
* Add a new point to geometryAdapter. |
|
241 |
* |
Also available in: Unified diff