Revision 906

View differences:

tags/org.gvsig.app.document.layout2.app-2.0.146/org.gvsig.app.document.layout2.app.mainplugin/buildNumber.properties
1
#Wed Mar 11 00:29:45 CET 2020
2
buildNumber=165
0 3

  
tags/org.gvsig.app.document.layout2.app-2.0.146/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>
tags/org.gvsig.app.document.layout2.app-2.0.146/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.
0 9

  
tags/org.gvsig.app.document.layout2.app-2.0.146/org.gvsig.app.document.layout2.app.mainplugin/src/main/assembly/gvsig-plugin-package.xml
1
<assembly>
2
  <id>gvsig-plugin-package</id>
3
  <formats>
4
    <format>zip</format>
5
  </formats>
6
  <baseDirectory>${project.artifactId}</baseDirectory>
7
  <includeBaseDirectory>true</includeBaseDirectory>
8
  <files>
9
    <file>
10
      <source>target/${project.artifactId}-${project.version}.jar</source>
11
      <outputDirectory>lib</outputDirectory>
12
    </file>
13
    <file>
14
      <source>target/package.info</source>
15
    </file>
16
  </files>
17

  
18
  <fileSets>
19
    <fileSet>
20
      <directory>src/main/resources-plugin</directory>
21
      <outputDirectory>.</outputDirectory>
22
    </fileSet>
23
  </fileSets>
24

  
25
  <dependencySets>
26
  
27
  <!--
28
    <dependencySet>
29
      <useProjectArtifact>false</useProjectArtifact>
30
      <useTransitiveDependencies>false</useTransitiveDependencies>
31
      <outputDirectory>lib</outputDirectory>
32
      <includes>
33
      </includes>
34
    </dependencySet>
35
    
36
    -->
37
    
38
  </dependencySets>
39

  
40
</assembly>
0 41

  
tags/org.gvsig.app.document.layout2.app-2.0.146/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.146/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
}
tags/org.gvsig.app.document.layout2.app-2.0.146/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.146/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
}
0 33

  
tags/org.gvsig.app.document.layout2.app-2.0.146/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/fframes/IFFrameEditableVertex.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.app.project.documents.layout.fframes;
23

  
24
import java.awt.Graphics2D;
25
import java.awt.geom.AffineTransform;
26
import java.awt.geom.Point2D;
27

  
28
import org.gvsig.app.project.documents.layout.geometryadapters.GeometryAdapter;
29

  
30
public interface IFFrameEditableVertex {
31

  
32
    void startEditing();
33

  
34
    void stopEditing();
35

  
36
    boolean isEditing();
37

  
38
    void pointPressed(Point2D point);
39

  
40
    void pointReleased(Point2D point, GeometryAdapter geom);
41

  
42
    void pointDragged(Point2D point);
43

  
44
    void paint(Graphics2D g, AffineTransform at);
45

  
46
    GeometryAdapter getGeometry();
47
}
tags/org.gvsig.app.document.layout2.app-2.0.146/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/fframes/FFrameBasic.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.app.project.documents.layout.fframes;
23

  
24
import java.awt.Color;
25
import java.awt.Graphics2D;
26
import java.awt.event.MouseEvent;
27
import java.awt.geom.AffineTransform;
28
import java.awt.geom.Point2D;
29
import java.awt.geom.Point2D.Double;
30
import java.awt.geom.Rectangle2D;
31
import java.awt.image.BufferedImage;
32

  
33
import org.gvsig.andami.PluginServices;
34
import org.gvsig.app.project.documents.layout.geometryadapters.PolygonAdapter;
35
import org.gvsig.compat.print.PrintAttributes;
36
import org.gvsig.fmap.geom.Geometry;
37
import org.gvsig.fmap.mapcontext.MapContextLocator;
38
import org.gvsig.fmap.mapcontext.MapContextManager;
39
import org.gvsig.symbology.SymbologyLocator;
40
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.IFillSymbol;
41
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.line.ISimpleLineSymbol;
42
import org.gvsig.tools.ToolsLocator;
43
import org.gvsig.tools.dynobject.DynStruct;
44
import org.gvsig.tools.persistence.PersistenceManager;
45
import org.gvsig.tools.persistence.PersistentState;
46
import org.gvsig.tools.persistence.exception.PersistenceException;
47

  
48
/**
49
 * FFrame b?sica que contiene una FFrame de cualquier tipo.
50
 * 
51
 * @author Vicente Caballero Navarro
52
 */
53
public class FFrameBasic extends FFrame {
54

  
55
    public static final String PERSISTENCE_DEFINITION_NAME = "FFrameBasic";
56

  
57
    private static final String FFRAMEGRAPHICS_FIELD = "fframeGraphics";
58
    private static final String FFRAME_FIELD = "fframe";
59

  
60
    private FFrameGraphics fframeGraphics;
61
    private IFFrame fframe;
62

  
63
    private MapContextManager mapContextManager = MapContextLocator
64
        .getMapContextManager();
65

  
66
    public void setRectangle(Rectangle2D r) {
67
        FFrameGraphics graphics =
68
            (FFrameGraphics) layoutManager
69
                .createFrame(FFrameGraphics.PERSISTENCE_DEFINITION_NAME);
70
        PolygonAdapter pa = new PolygonAdapter();
71
        pa.addPoint(new Point2D.Double(r.getX(), r.getY()));
72
        pa.addPoint(new Point2D.Double(r.getMaxX(), r.getY()));
73
        pa.addPoint(new Point2D.Double(r.getMaxX(), r.getMaxY()));
74
        pa.addPoint(new Point2D.Double(r.getX(), r.getMaxY()));
75
        pa.addPoint(new Point2D.Double(r.getX(), r.getY()));
76
        pa.end();
77
        graphics.setGeometryAdapter(pa);
78
        graphics.setBoundBox(r);
79

  
80
        IFillSymbol symbol =
81
            (IFillSymbol) mapContextManager.getSymbolManager().createSymbol(
82
                IFillSymbol.SYMBOL_NAME);
83
        symbol.setFillColor(new Color(255, 255, 255, 0));
84
        ISimpleLineSymbol blackOutline =
85
            SymbologyLocator.getSymbologyManager().createSimpleLineSymbol();
86
        blackOutline.setLineColor(Color.BLACK);
87
        symbol.setOutline(blackOutline);
88
        graphics.setSymbol(symbol);
89
        graphics.setType(Geometry.TYPES.CURVE);
90
        setFframeGraphics(graphics);
91
    }
92

  
93
    public FFrameBasic() {
94

  
95
    }
96

  
97
    /**
98
     * M?todo que dibuja sobre el graphics que se le pasa como par?metro, seg?n
99
     * la transformada afin que se debe de aplicar y el rect?ngulo que se debe
100
     * de dibujar.
101
     * 
102
     * @param g
103
     *            Graphics
104
     * @param at
105
     *            Transformada afin.
106
     * @param rv
107
     *            rect?ngulo sobre el que hacer un clip.
108
     * @param imgBase
109
     *            Imagen para acelerar el dibujado.
110
     */
111
    public void draw(Graphics2D g, AffineTransform at, Rectangle2D rv,
112
        BufferedImage imgBase) {
113
        fframeGraphics.draw(g, at, rv, imgBase);
114
        if (fframe != null) {
115
            fframe.draw(g, at, rv, imgBase);
116
        }
117
    }
118

  
119
    /**
120
     * @see org.gvsig.app.project.documents.layout.fframes.IFFrame#getNameFFrame()
121
     */
122
    public String getNameFFrame() {
123
        return PluginServices.getText(this, "base") + num;
124
    }
125

  
126
    /**
127
     * @see org.gvsig.app.project.documents.layout.fframes.IFFrame#print(java.awt.Graphics2D,
128
     *      java.awt.geom.AffineTransform)
129
     */
130
    public void print(Graphics2D g, AffineTransform at, Geometry geom,
131
        PrintAttributes printingProperties) {
132
        fframeGraphics.print(g, at, geom, printingProperties);
133
        if (fframe != null) {
134
            fframe.print(g, at, geom, printingProperties);
135
        }
136
    }
137

  
138
    public IFFrame getFframe() {
139
        return fframe;
140
    }
141

  
142
    public void setFframe(IFFrame fframe) {
143
        this.fframe = fframe;
144
    }
145

  
146
    public FFrameGraphics getFframeGraphics() {
147
        return fframeGraphics;
148
    }
149

  
150
    public void setFframeGraphics(FFrameGraphics fframeGraphics) {
151
        this.fframeGraphics = fframeGraphics;
152
    }
153

  
154
    public void drawHandlers(Graphics2D g) {
155
        fframeGraphics.drawHandlers(g);
156
    }
157

  
158
    public IFFrame clone() throws CloneNotSupportedException {
159
        FFrameBasic basic = new FFrameBasic();
160
        basic.setFframeGraphics((FFrameGraphics) fframeGraphics.clone());
161
        if (fframe != null) {
162
            basic.setFframe((IFFrame) fframe.clone());
163
        }
164
        return basic;
165
    }
166

  
167
    public boolean contains(Double p) {
168
        return getFframeGraphics().contains(p);
169
    }
170

  
171
    public void drawDraft(Graphics2D g) {
172
        super.drawDraft(g);
173
    }
174

  
175
    public void drawEmpty(Graphics2D g) {
176
        super.drawEmpty(g);
177
    }
178

  
179
    public void drawSymbolTag(Graphics2D g) {
180
        super.drawSymbolTag(g);
181
    }
182

  
183
    public java.awt.geom.Rectangle2D.Double getBoundBox() {
184
        return getFframeGraphics().getBoundBox();
185
    }
186

  
187
    public java.awt.geom.Rectangle2D.Double getBoundingBox(AffineTransform at) {
188
        return getFframeGraphics().getBoundingBox(at);
189
    }
190

  
191
    public int getContains(Double p) {
192
        return getFframeGraphics().getContains(p);
193
    }
194

  
195
    public int getLevel() {
196
        return super.getLevel();
197
    }
198

  
199
    public Rectangle2D getMovieRect(int difx, int dify) {
200
        return fframeGraphics.getMovieRect(difx, dify);
201
    }
202

  
203
    public String getName() {
204
        return PERSISTENCE_DEFINITION_NAME;
205
    }
206

  
207
    public double getRotation() {
208
        return super.getRotation();
209
    }
210

  
211
    public int getSelected() {
212
        return fframeGraphics.getSelected();
213
    }
214

  
215
    public String getTag() {
216
        return super.getTag();
217
    }
218

  
219
    public boolean intersects(Rectangle2D rv, Rectangle2D r) {
220
        return super.intersects(rv, r);
221
    }
222

  
223
    public void setBoundBox(Rectangle2D r) {
224
        if (getFframeGraphics() != null) {
225
            getFframeGraphics().setBoundBox(r);
226
        }
227
        if (getFframe() != null) {
228
            getFframe().setBoundBox(r);
229
        }
230
    }
231

  
232
    public void setLevel(int l) {
233
        super.setLevel(l);
234
    }
235

  
236
    public void setNum(int i) {
237
        super.setNum(i);
238
    }
239

  
240
    public void setRotation(double rotation) {
241
        super.setRotation(rotation);
242
    }
243

  
244
    public void setSelected(boolean b) {
245
        fframeGraphics.setSelected(b);
246
    }
247

  
248
    public void setSelected(Point2D p, MouseEvent e) {
249
        fframeGraphics.setSelected(p, e);
250
    }
251

  
252
    public void setTag(String s) {
253
        super.setTag(s);
254
    }
255

  
256
    public void updateRect(Rectangle2D r, AffineTransform at) {
257
        getFframeGraphics().updateRect(r, at);
258
    }
259

  
260
    public static void registerPersistent() {
261
        PersistenceManager manager = ToolsLocator.getPersistenceManager();
262
        if (manager.getDefinition(PERSISTENCE_DEFINITION_NAME) == null) {
263
            DynStruct definition =
264
                manager.addDefinition(FFrameBasic.class,
265
                    PERSISTENCE_DEFINITION_NAME,
266
                    "FFrameBasic persistence definition", null, null);
267

  
268
            definition.extend(manager
269
                .getDefinition(FFrame.PERSISTENCE_DEFINITION_NAME));
270

  
271
            definition.addDynFieldObject(FFRAMEGRAPHICS_FIELD)
272
                .setClassOfValue(FFrameGraphics.class).setMandatory(true);
273
            definition.addDynFieldDouble(FFRAME_FIELD);
274
        }
275
    }
276

  
277
    @Override
278
    public void loadFromState(PersistentState state)
279
        throws PersistenceException {
280
        super.loadFromState(state);
281
        fframeGraphics = (FFrameGraphics) state.get(FFRAMEGRAPHICS_FIELD);
282
        fframe = (IFFrame) state.get(FFRAME_FIELD);
283
    }
284

  
285
    @Override
286
    public void saveToState(PersistentState state) throws PersistenceException {
287
        super.saveToState(state);
288
        state.set(FFRAMEGRAPHICS_FIELD, fframeGraphics);
289
        state.set(FFRAME_FIELD, fframe);
290
    }
291
}
tags/org.gvsig.app.document.layout2.app-2.0.146/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/fframes/FFrameNorthFactory.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.app.project.documents.layout.fframes;
23

  
24
import org.gvsig.andami.PluginServices;
25

  
26
/**
27
 * Factory of FFrameNorth.
28
 * 
29
 * @author Vicente Caballero Navarro
30
 */
31
public class FFrameNorthFactory extends FrameFactory {
32

  
33
    /**
34
     * Create a new IFFrame.
35
     * 
36
     * @return IFFrame.
37
     */
38
    public IFFrame createFrame() {
39
        FFrameNorth north = new FFrameNorth();
40
        north.setFrameFactory(this);
41
        return north;
42
    }
43

  
44
    /**
45
     * Returns the name of registration in the point of extension.
46
     * 
47
     * @return Name of registration
48
     */
49
    public String getRegisterName() {
50
        return FFrameNorth.PERSISTENCE_DEFINITION_NAME;
51
    }
52

  
53
    /**
54
     * Returns the name of IFFrame.
55
     * 
56
     * @return Name of IFFrame.
57
     */
58
    public String getNameType() {
59
        return PluginServices.getText(this, "FFrameNorth");
60
    }
61
}
tags/org.gvsig.app.document.layout2.app-2.0.146/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/fframes/gui/JPRotation.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.app.project.documents.layout.fframes.gui;
23

  
24
import java.awt.BorderLayout;
25
import java.awt.Component;
26
import java.awt.event.FocusEvent;
27
import java.awt.event.FocusListener;
28
import java.awt.event.KeyEvent;
29

  
30
import javax.swing.JButton;
31
import javax.swing.JOptionPane;
32
import javax.swing.JPanel;
33
import javax.swing.JTextField;
34

  
35
import org.gvsig.andami.PluginServices;
36

  
37
public class JPRotation extends JPanel {
38

  
39
    private static final long serialVersionUID = 5537314374490402138L;
40
    private JPRotationView pRotationView = null;
41
    private JPanel pButtons = null;
42
    private JButton bLeft = null;
43
    private JTextField txtRotation = null;
44
    private String parsedText = null;
45
    private JButton bRight = null;
46

  
47
    public void setRotation(double rot) {
48
        getPRotationView().setRotation(rot);
49
        setTextRotation(rot);
50
    }
51

  
52
    private void setTextRotation(double d) {
53
        String s = String.valueOf(d);
54
        if (s.endsWith(".0")) {
55
            txtRotation.setText(s.substring(0, s.length() - 2));
56
        } else {
57
            txtRotation.setText(s);
58
        }
59
    }
60

  
61
    public double getRotation() {
62
        return getPRotationView().getRotation();
63
    }
64

  
65
    /**
66
     * This method initializes pRotationView
67
     * 
68
     * @return javax.swing.JPanel
69
     */
70
    private JPRotationView getPRotationView() {
71
        if (pRotationView == null) {
72
            pRotationView = new JPRotationView();
73
            pRotationView.setForeground(java.awt.Color.black);
74
            pRotationView.setBackground(java.awt.SystemColor.controlShadow);
75
            pRotationView.setPreferredSize(new java.awt.Dimension(80, 50));
76
        }
77
        return pRotationView;
78
    }
79

  
80
    /**
81
     * This method initializes pButtons
82
     * 
83
     * @return javax.swing.JPanel
84
     */
85
    private JPanel getPButtons() {
86
        if (pButtons == null) {
87
            pButtons = new JPanel();
88
            pButtons.add(getBLeft(), null);
89
            pButtons.add(getTxtRotation(), null);
90
            pButtons.add(getBRight(), null);
91
        }
92
        return pButtons;
93
    }
94

  
95
    /**
96
     * This method initializes bLeft
97
     * 
98
     * @return javax.swing.JButton
99
     */
100
    private JButton getBLeft() {
101
        if (bLeft == null) {
102
            bLeft = new JButton();
103
            bLeft.setPreferredSize(new java.awt.Dimension(24, 24));
104
            bLeft.setIcon(PluginServices.getIconTheme().get(
105
                "left-rotation-icon"));
106
            bLeft.addActionListener(new java.awt.event.ActionListener() {
107

  
108
                public void actionPerformed(java.awt.event.ActionEvent e) {
109
                    setRotation(Double.parseDouble(txtRotation.getText()) + 1);
110
                    getTxtRotation().setText(txtRotation.getText());
111
                    getPRotationView().repaint();
112
                }
113
            });
114
        }
115
        return bLeft;
116
    }
117

  
118
    /**
119
     * This method initializes txtRotation
120
     * 
121
     * @return javax.swing.JTextField
122
     */
123
    private JTextField getTxtRotation() {
124
        if (txtRotation == null) {
125
            txtRotation = new JTextField();
126
            txtRotation.setPreferredSize(new java.awt.Dimension(45, 24));
127
            txtRotation.addFocusListener(new FocusListener() {
128
				
129
				public void focusLost(FocusEvent e) {
130
                    if (txtRotation.getText().endsWith(".")) {
131
                        return;
132
                    }
133
                    try {
134
                        setRotation(Double.parseDouble(txtRotation.getText()));
135
                    } catch (NumberFormatException e1) {
136
                    	String oldText = parsedText;
137
                    	parsedText = txtRotation.getText();
138
                    	if (!parsedText.equals(oldText)) { // don't show more than once for the same string
139
                    		JOptionPane.showMessageDialog(
140
                    				(Component) PluginServices.getMainFrame(),
141
                    				PluginServices.getText(this, "numero_incorrecto"));
142
                    	}
143
                    }
144
                    getPRotationView().repaint();				}
145
				
146
				public void focusGained(FocusEvent e) {
147
				}
148
			});
149
            txtRotation.addKeyListener(new java.awt.event.KeyAdapter() {
150

  
151
                public void keyReleased(java.awt.event.KeyEvent e) {
152
                	String text = txtRotation.getText();
153
                	if (text.endsWith(".")) {
154
                		return;
155
                	}
156
					Double value = getDouble(text);
157
					if (value!=null) {
158
						setRotation(value);
159
						getPRotationView().repaint();
160
					}
161
					else if (e.getKeyCode()==KeyEvent.VK_ENTER) {
162
                    	String oldText = parsedText;
163
                    	parsedText = txtRotation.getText();
164
                    	if (!parsedText.equals(oldText)) { // don't show more than once for the same string
165
                    		JOptionPane.showMessageDialog(
166
                    				(Component) PluginServices.getMainFrame(),
167
                    				PluginServices.getText(this, "numero_incorrecto"));
168
                    	}
169
					}
170
                }
171
            });
172
            setTextRotation(getRotation());
173
        }
174
        return txtRotation;
175
    }
176
    
177
    protected Double getDouble(String strValue) {
178
		// allow comma separated decimal values
179
		String text = strValue.replaceAll(",", ".");
180
		try {
181
			return Double.parseDouble(text);
182
		} catch (NumberFormatException e1) {
183
		}
184
		return null;
185
    }
186

  
187
    /**
188
     * This method initializes bRight
189
     * 
190
     * @return javax.swing.JButton
191
     */
192
    private JButton getBRight() {
193
        if (bRight == null) {
194
            bRight = new JButton();
195
            bRight.setPreferredSize(new java.awt.Dimension(24, 24));
196
            bRight.setIcon(PluginServices.getIconTheme().get(
197
                "right-rotation-icon"));
198
            bRight.addActionListener(new java.awt.event.ActionListener() {
199

  
200
                public void actionPerformed(java.awt.event.ActionEvent e) {
201
                    setRotation(Double.parseDouble(txtRotation.getText()) - 1);
202
                    getTxtRotation().setText(txtRotation.getText());
203
                    getPRotationView().repaint();
204
                }
205
            });
206
        }
207
        return bRight;
208
    }
209

  
210
    /**
211
     * @param args
212
     */
213
    public static void main(String[] args) {
214

  
215
    }
216

  
217
    /**
218
     * This is the default constructor
219
     */
220
    public JPRotation() {
221
        super();
222
        initialize();
223
    }
224

  
225
    /**
226
     * This method initializes this
227
     * 
228
     * @return void
229
     */
230
    private void initialize() {
231
        this.setLayout(new BorderLayout());
232
        this.setBorder(javax.swing.BorderFactory.createTitledBorder(null,
233
            PluginServices.getText(this, "grados"),
234
            javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
235
            javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
236
        this.add(getPRotationView(), java.awt.BorderLayout.NORTH);
237
        this.add(getPButtons(), java.awt.BorderLayout.SOUTH);
238
    }
239

  
240
} // @jve:decl-index=0:visual-constraint="10,26"
tags/org.gvsig.app.document.layout2.app-2.0.146/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/fframes/gui/EnvelopePanel.java
1
package org.gvsig.app.project.documents.layout.fframes.gui;
2

  
3
import java.awt.GridBagConstraints;
4
import java.awt.GridBagLayout;
5
import java.awt.Insets;
6
import java.text.DecimalFormat;
7
import java.text.NumberFormat;
8
import java.text.ParseException;
9

  
10
import javax.swing.JLabel;
11
import javax.swing.JPanel;
12
import javax.swing.JTextField;
13
import javax.swing.text.NumberFormatter;
14

  
15
import org.gvsig.fmap.geom.Geometry;
16
import org.gvsig.fmap.geom.GeometryLocator;
17
import org.gvsig.fmap.geom.GeometryManager;
18
import org.gvsig.fmap.geom.exception.CreateEnvelopeException;
19
import org.gvsig.fmap.geom.primitive.Envelope;
20
import org.gvsig.i18n.Messages;
21
import org.slf4j.LoggerFactory;
22

  
23

  
24
public class EnvelopePanel extends JPanel {
25
	private static final long serialVersionUID = -1828624765045725544L;
26
	private JTextField fldTop = null;
27
	private JTextField fldLeft = null;
28
	private JTextField fldRight = null;
29
	private JTextField fldBottom = null;
30
	private static final GeometryManager geoMgr = GeometryLocator.getGeometryManager();
31
	private int fieldWidth;
32
	private DecimalFormat formatLatLon = new DecimalFormat("0.######");
33
	private DecimalFormat formatMetres = new DecimalFormat("0.##");
34
	
35
	public EnvelopePanel() {
36
		this(8);
37
	}
38
	
39
	public EnvelopePanel(int fieldWidth) {
40
		super(new GridBagLayout());
41
		this.fieldWidth = fieldWidth;
42
		initComponents();
43
	}
44
	
45
	protected void initComponents() {
46
		int row = 0;
47
		GridBagConstraints c = new GridBagConstraints();
48
		c.gridy = row++;
49
		c.gridx = 1;
50
		c.anchor = GridBagConstraints.LINE_END;
51
		c.insets = new Insets(0, 5, 5, 5);
52
		JLabel label = new JLabel(Messages.getText("Top_extent_lbl"));
53
		add(label, c);
54
		c.gridx = 2;
55
		c.anchor = GridBagConstraints.LINE_START;
56
		add(getFldTop(), c);
57
		
58
		c.gridy = row++;
59
		c.gridx = 0;
60
		c.insets = new Insets(5, 0, 5, 5);
61
		c.anchor = GridBagConstraints.LINE_END;
62
		label = new JLabel(Messages.getText("Left_extent_lbl"));
63
		add(label, c);
64
		c.gridx = 1;
65
		c.insets = new Insets(5, 5, 5, 5);
66
		c.anchor = GridBagConstraints.LINE_START;
67
		add(getFldLeft(), c);		
68

  
69
		c.gridx = 3;
70
		c.anchor = GridBagConstraints.LINE_END;
71
		label = new JLabel(Messages.getText("Right_extent_lbl"));
72
		add(label, c);
73
		c.gridx = 4;
74
		c.anchor = GridBagConstraints.LINE_START;
75
		c.insets = new Insets(5, 5, 5, 0);
76
		add(getFldRight(), c);
77
		
78
		c.gridy = row++;
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff