Revision 270

View differences:

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

  
24
import java.awt.Color;
25
import java.awt.Cursor;
26
import java.awt.Graphics;
27
import java.awt.Graphics2D;
28
import java.awt.Image;
29
import java.awt.Point;
30
import java.awt.Rectangle;
31
import java.awt.Toolkit;
32
import java.awt.geom.AffineTransform;
33
import java.awt.geom.Rectangle2D;
34
import java.awt.image.BufferedImage;
35
import java.awt.image.MemoryImageSource;
36
import java.util.HashMap;
37

  
38
import javax.swing.JComponent;
39

  
40
import org.gvsig.andami.PluginsLocator;
41
import org.gvsig.app.project.documents.layout.fframes.IFFrame;
42
import org.gvsig.app.project.documents.layout.fframes.IFFrameEditableVertex;
43
import org.gvsig.app.project.documents.layout.fframes.IFFrameUseFMap;
44
import org.gvsig.app.project.documents.layout.geometryadapters.GeometryAdapter;
45
import org.gvsig.app.project.documents.layout.geometryadapters.PolyLineAdapter;
46
import org.gvsig.app.project.documents.layout.gui.LayoutPanel;
47
import org.gvsig.app.project.documents.layout.tools.LayoutAddBoxListenerImpl;
48
import org.gvsig.app.project.documents.layout.tools.LayoutAddCircleListenerImpl;
49
import org.gvsig.app.project.documents.layout.tools.LayoutAddLegendListenerImpl;
50
import org.gvsig.app.project.documents.layout.tools.LayoutAddLineListenerImpl;
51
import org.gvsig.app.project.documents.layout.tools.LayoutAddNorthListenerImpl;
52
import org.gvsig.app.project.documents.layout.tools.LayoutAddOverViewListenerImpl;
53
import org.gvsig.app.project.documents.layout.tools.LayoutAddPictureListenerImpl;
54
import org.gvsig.app.project.documents.layout.tools.LayoutAddPointListenerImpl;
55
import org.gvsig.app.project.documents.layout.tools.LayoutAddPolygonListenerImpl;
56
import org.gvsig.app.project.documents.layout.tools.LayoutAddPolylineListenerImpl;
57
import org.gvsig.app.project.documents.layout.tools.LayoutAddRectangleListenerImpl;
58
import org.gvsig.app.project.documents.layout.tools.LayoutAddScaleListenerImpl;
59
import org.gvsig.app.project.documents.layout.tools.LayoutAddTextListenerImpl;
60
import org.gvsig.app.project.documents.layout.tools.LayoutAddViewListenerImpl;
61
import org.gvsig.app.project.documents.layout.tools.LayoutEditGraphicsListenerImpl;
62
import org.gvsig.app.project.documents.layout.tools.LayoutPanListenerImpl;
63
import org.gvsig.app.project.documents.layout.tools.LayoutSelectListenerImpl;
64
import org.gvsig.app.project.documents.layout.tools.LayoutViewPanListenerImpl;
65
import org.gvsig.app.project.documents.layout.tools.LayoutViewZoomInListenerImpl;
66
import org.gvsig.app.project.documents.layout.tools.LayoutViewZoomOutListenerImpl;
67
import org.gvsig.app.project.documents.layout.tools.LayoutZoomInListenerImpl;
68
import org.gvsig.app.project.documents.layout.tools.LayoutZoomOutListenerImpl;
69
import org.gvsig.app.project.documents.layout.tools.behavior.LayoutBehavior;
70
import org.gvsig.app.project.documents.layout.tools.behavior.LayoutEditBehavior;
71
import org.gvsig.app.project.documents.layout.tools.behavior.LayoutMoveBehavior;
72
import org.gvsig.app.project.documents.layout.tools.behavior.LayoutPointBehavior;
73
import org.gvsig.app.project.documents.layout.tools.behavior.LayoutRectangleBehavior;
74
import org.gvsig.app.project.documents.layout.tools.behavior.LayoutSelectBehavior;
75
import org.gvsig.app.project.documents.layout.tools.behavior.LayoutViewMoveBehavior;
76
import org.gvsig.app.project.documents.layout.tools.behavior.LayoutViewZoomBehavior;
77
import org.gvsig.app.project.documents.layout.tools.behavior.LayoutZoomBehavior;
78
import org.gvsig.app.project.documents.layout.tools.listener.ILayoutGraphicListener;
79
import org.gvsig.fmap.dal.exception.ReadException;
80
import org.gvsig.tools.observer.Observable;
81

  
82
/**
83
 * Control of Layout.
84
 * 
85
 * @author Vicente Caballero Navarro
86
 */
87
public class DefaultLayoutControl extends JComponent implements LayoutControl {
88
    private static final int DESACTUALIZADO = 4;
89
    private static final int ACTUALIZADO = 5;
90
    
91
    private static final long serialVersionUID = -8290006366669291510L;
92

  
93
    public static final String PERSISTENCE_DEFINITION_NAME = "LayoutControl";
94

  
95
    private int status = DESACTUALIZADO;
96
    private Rectangle2D rectVisible;
97
    private BufferedImage img = null;
98
    private BufferedImage imgRuler = null;
99
    private boolean initial = true;
100
    private LayoutContext layoutContext;
101
    private Point origin = new Point(50, 50);
102
    private Point rectOrigin = new Point(origin);
103
    private Rectangle2D.Double rect = new Rectangle2D.Double(rectOrigin.x,
104
        rectOrigin.y, 400, 300);
105
    private FLayoutDraw layoutDraw = null;
106
    private FLayoutFunctions layoutFunctions = null;
107
    private LayoutBehavior currentLayoutTool = null;
108
    private Image imageCursor = null;
109
    private HashMap namesLayoutTools = new HashMap();
110
    private Point m_FirstPoint = new Point(0, 0);
111
    private Point m_PointAnt = new Point(0, 0);
112
    private Point m_LastPoint = new Point(0, 0);
113
    private LayoutEvents layoutEvents;
114
    private Point position;
115
    private GeometryAdapter geometryAdapter = new PolyLineAdapter();
116

  
117
    // private String prevTool;
118
    private String currentTool;
119
    private boolean m_bCancelDrawing = false;
120
    private Rectangle reSel = null;
121
    private boolean isReSel = true;
122
    private FLayoutZooms layoutZooms;
123
	private LayoutPanel layoutPanel;
124

  
125
    private static Cursor transparentCursor = Toolkit.getDefaultToolkit()
126
        .createCustomCursor(
127
            Toolkit.getDefaultToolkit().createImage(
128
                new MemoryImageSource(16, 16, new int[16 * 16], 0, 16)),
129
            new Point(0, 0), "invisiblecursor");
130

  
131
    /**
132
     * Create a new object of LayoutControl.
133
     * 
134
     * @param layout
135
     */
136
    public DefaultLayoutControl() {  
137
               
138
    }
139
    
140
    public void initialize(LayoutPanel layoutPanel){
141
    	setFocusable(true);
142
    	this.layoutPanel = layoutPanel;
143
        layoutDraw = new FLayoutDraw(layoutPanel);
144
        layoutEvents = new LayoutEvents(layoutPanel);
145
        layoutZooms = new FLayoutZooms(layoutPanel);
146
        layoutFunctions = new FLayoutFunctions(layoutPanel);
147
        addComponentListener(layoutEvents);
148
        addMouseMotionListener(layoutEvents);
149
        addMouseListener(layoutEvents);
150

  
151
        LayoutPanListenerImpl lpl = new LayoutPanListenerImpl(layoutPanel);
152
        addLayoutTool("layoutpan", new LayoutMoveBehavior(lpl));
153

  
154
        LayoutZoomInListenerImpl lzil = new LayoutZoomInListenerImpl(layoutPanel);
155
        addLayoutTool("layoutzoomin", new LayoutZoomBehavior(lzil));
156

  
157
        LayoutZoomOutListenerImpl lzol = new LayoutZoomOutListenerImpl(layoutPanel);
158
        addLayoutTool("layoutzoomout", new LayoutZoomBehavior(lzol));
159

  
160
        LayoutAddViewListenerImpl lavl = new LayoutAddViewListenerImpl(layoutPanel);
161
        addLayoutTool("layoutaddview", new LayoutRectangleBehavior(lavl));
162

  
163
        LayoutAddOverViewListenerImpl laovl =
164
            new LayoutAddOverViewListenerImpl(layoutPanel);
165
        addLayoutTool("layoutaddoverview", new LayoutRectangleBehavior(laovl));
166

  
167
        LayoutAddPictureListenerImpl lapl =
168
            new LayoutAddPictureListenerImpl(layoutPanel);
169
        addLayoutTool("layoutaddpicture", new LayoutRectangleBehavior(lapl));
170

  
171
        LayoutAddNorthListenerImpl lanorthl =
172
            new LayoutAddNorthListenerImpl(layoutPanel);
173
        addLayoutTool("layoutaddnorth", new LayoutRectangleBehavior(lanorthl));
174

  
175
        LayoutAddScaleListenerImpl lasl =
176
            new LayoutAddScaleListenerImpl(layoutPanel);
177
        addLayoutTool("layoutaddscale", new LayoutRectangleBehavior(lasl));
178

  
179
        LayoutAddLegendListenerImpl lall =
180
            new LayoutAddLegendListenerImpl(layoutPanel);
181
        addLayoutTool("layoutaddlegend", new LayoutRectangleBehavior(lall));
182

  
183
        LayoutAddTextListenerImpl latl = new LayoutAddTextListenerImpl(layoutPanel);
184
        addLayoutTool("layoutaddtext", new LayoutRectangleBehavior(latl));
185

  
186
        LayoutAddBoxListenerImpl labl = new LayoutAddBoxListenerImpl(layoutPanel);
187
        addLayoutTool("layoutaddbox", new LayoutRectangleBehavior(labl));
188

  
189
        LayoutAddPointListenerImpl lapointl =
190
            new LayoutAddPointListenerImpl(layoutPanel);
191
        addLayoutTool("layoutaddpoint", new LayoutPointBehavior(lapointl));
192

  
193
        LayoutAddLineListenerImpl lalinel =
194
            new LayoutAddLineListenerImpl(layoutPanel);
195
        addLayoutTool("layoutaddline", new LayoutPointBehavior(lalinel));
196

  
197
        LayoutAddPolygonListenerImpl lapolygonl =
198
            new LayoutAddPolygonListenerImpl(layoutPanel);
199
        addLayoutTool("layoutaddpolygon", new LayoutPointBehavior(lapolygonl));
200

  
201
        LayoutAddPolylineListenerImpl lapolylinel =
202
            new LayoutAddPolylineListenerImpl(layoutPanel);
203
        addLayoutTool("layoutaddpolyline", new LayoutPointBehavior(lapolylinel));
204

  
205
        LayoutAddCircleListenerImpl lacirclel =
206
            new LayoutAddCircleListenerImpl(layoutPanel);
207
        addLayoutTool("layoutaddcircle", new LayoutPointBehavior(lacirclel));
208

  
209
        LayoutAddRectangleListenerImpl larectanglel =
210
            new LayoutAddRectangleListenerImpl(layoutPanel);
211
        addLayoutTool("layoutaddrectangle", new LayoutPointBehavior(
212
            larectanglel));
213

  
214
        LayoutViewPanListenerImpl lvpl = new LayoutViewPanListenerImpl(layoutPanel);
215
        addLayoutTool("layoutviewpan", new LayoutViewMoveBehavior(lvpl));
216

  
217
        LayoutViewZoomInListenerImpl lvzil =
218
            new LayoutViewZoomInListenerImpl(layoutPanel);
219
        addLayoutTool("layoutviewzoomin", new LayoutViewZoomBehavior(lvzil));
220

  
221
        LayoutViewZoomOutListenerImpl lvzol =
222
            new LayoutViewZoomOutListenerImpl(layoutPanel);
223
        addLayoutTool("layoutviewzoomout", new LayoutViewZoomBehavior(lvzol));
224

  
225
        LayoutSelectListenerImpl lselectl =
226
            new LayoutSelectListenerImpl(layoutPanel);
227
        addLayoutTool("layoutselect", new LayoutSelectBehavior(lselectl));
228

  
229
        LayoutEditGraphicsListenerImpl leditl =
230
            new LayoutEditGraphicsListenerImpl(layoutPanel);
231
        addLayoutTool("layoutedit", new LayoutEditBehavior(leditl));
232
    }
233

  
234
    public String getCurrentTool() {
235
        return currentTool;
236
    }
237

  
238
    public void addLayoutTool(String name, LayoutBehavior tool) {
239
        namesLayoutTools.put(name, tool);
240
        tool.setLayoutControl(this);
241
    }
242

  
243
    public void setLayoutContext(LayoutContext lc) {
244
        layoutContext = lc;
245
        layoutContext.addObserver(this);
246
        fullRect();
247
    }
248

  
249
    /**
250
     * paintComponent of Layout.
251
     * 
252
     * @param g
253
     *            Graphics of Layout.
254
     */
255
    protected void paintComponent(Graphics g) {
256
        clipVisibleRect((Graphics2D) g);
257

  
258
        Rectangle rClip = g.getClipBounds();
259

  
260
        if (rClip == null) {
261
            System.err.println("clip = null");
262
        }
263

  
264
        switch (status) {
265
        case DESACTUALIZADO:
266
            if (getWidth() == 0) {
267
                return;
268
            }
269

  
270
            img =
271
                new BufferedImage(getWidth(), getHeight(),
272
                    BufferedImage.TYPE_INT_ARGB);
273
            imgRuler =
274
                new BufferedImage(getWidth(), getHeight(),
275
                    BufferedImage.TYPE_INT_ARGB);
276

  
277
            Graphics gimag = img.getGraphics();
278
            Graphics gimgRuler = imgRuler.getGraphics();
279
            clipVisibleRect((Graphics2D) gimag);
280

  
281
            try {
282
                layoutDraw.drawLayout((Graphics2D) gimag, img);
283
            } catch (ReadException e) {
284
                e.printStackTrace();
285
            }
286

  
287
            g.setClip(rClip);
288
            layoutDraw.drawRectangle((Graphics2D) g);
289

  
290
            g.drawImage(img, 0, 0, this);
291
            g.setClip(rClip);
292

  
293
            layoutDraw.drawGrid((Graphics2D) gimgRuler);
294
            layoutDraw.drawRuler((Graphics2D) gimgRuler, Color.black);
295
            setStatus(ACTUALIZADO);
296
            repaint();
297

  
298
            break;
299

  
300
        case ACTUALIZADO:
301
            layoutDraw.drawRectangle((Graphics2D) g);
302

  
303
            if (currentLayoutTool != null) {
304
                currentLayoutTool.paintComponent(g);
305
            } else {
306
                g.drawImage(img, 0, 0, this);
307

  
308
                layoutDraw.drawHandlers((Graphics2D) g, Color.black);
309
            }
310

  
311
            g.setClip(rClip);
312
            drawCursor(g);
313
        }
314
    }
315

  
316
    private void setStatus(int s) {
317
        status = s;
318
    }
319

  
320
    /**
321
     * Clip on visible rectangle.
322
     * 
323
     * @param g2d
324
     *            Graphics.
325
     */
326
    private void clipVisibleRect(Graphics2D g2d) {
327
        rectVisible = this.getVisibleRect();
328
        g2d.clipRect((int) rectVisible.getMinX(), (int) rectVisible.getMinY(),
329
            (int) rectVisible.getWidth(), (int) rectVisible.getHeight());
330
    }
331

  
332
    public BufferedImage getImgRuler() {
333
        return imgRuler;
334
    }
335

  
336
    public void fullRect() {
337
        rect.setRect(origin.x, origin.y, getWidth() - (origin.x * 2),
338
            getHeight() - (origin.x * 2));
339

  
340
        if (layoutContext.getAttributes().isLandscape()) {
341
            rect =
342
                layoutContext.getAttributes().getRectangleLandscape(rect,
343
                    getWidth(), getHeight());
344
        } else {
345
            rect =
346
                layoutContext.getAttributes().getRectanglePortrait(rect,
347
                    getWidth(), getHeight());
348
        }
349

  
350
        refresh();
351
    }
352

  
353
    public Rectangle2D.Double getRect() {
354
        return rect;
355
    }
356

  
357
    public void setRect(Rectangle2D r) {
358
        rect.setRect(r);
359
    }
360

  
361
    public BufferedImage getImage() {
362
        return img;
363
    }
364

  
365
    /**
366
     * Draw the cursor on the Graphics.
367
     * 
368
     * @param g
369
     *            Graphics.
370
     */
371
    private void drawCursor(Graphics g) {
372
        if ((imageCursor != null) && (position != null)) {
373
            Point pAdjusted = position;
374
            g.drawImage(imageCursor, (int) pAdjusted.getX() - 16,
375
                (int) pAdjusted.getY() - 16, this);
376
        }
377
    }
378

  
379
    public void setMapCursor(Image image) {
380
        imageCursor = image;
381
    }
382

  
383
    public void setTool(String toolName) {
384
        LayoutBehavior layoutTool =
385
            (LayoutBehavior) namesLayoutTools.get(toolName);
386
        currentLayoutTool = layoutTool;
387
        currentLayoutTool.setLayoutControl(this);
388
        currentTool = toolName;
389
        this.setMapCursor(layoutTool.getImageCursor());
390

  
391
        if (getCurrentLayoutTool().getListener() instanceof ILayoutGraphicListener) {
392
            geometryAdapter =
393
                ((ILayoutGraphicListener) getCurrentLayoutTool().getListener())
394
                    .createGeometryAdapter();
395
        }
396

  
397
        if (getCurrentTool().equals("layoutedit")) {
398
            startEdit();
399
        } else {
400
            stopEdit();
401
        }
402
    }
403

  
404
	public void setDefaultTool() {
405
        PluginsLocator.getMainFrame().setSelectedTool("selection-select-by-rectangle-layout");
406
        setTool("layoutselect");
407
	}
408

  
409
    public void startEdit() {
410
        IFFrame[] fframes = layoutContext.getFFrames();
411

  
412
        for (int i = 0; i < fframes.length; i++) {
413
            IFFrame frame = fframes[i];
414

  
415
            if (frame instanceof IFFrameEditableVertex) {
416
                if (frame.getSelected() != IFFrame.NOSELECT) {
417
                    ((IFFrameEditableVertex) frame).startEditing();
418
                } else {
419
                    ((IFFrameEditableVertex) frame).stopEditing();
420
                }
421
            }
422
        }
423

  
424
        refresh();
425
    }
426

  
427
    public void stopEdit() {
428
        boolean refresh = false;
429
        IFFrame[] fframes = layoutContext.getFFrames();
430

  
431
        for (int i = 0; i < fframes.length; i++) {
432
            IFFrame frame = fframes[i];
433

  
434
            if (frame instanceof IFFrameEditableVertex) {
435
                if (((IFFrameEditableVertex) frame).isEditing()) {
436
                    ((IFFrameEditableVertex) fframes[i]).stopEditing();
437
                    refresh = true;
438
                }
439
            }
440
        }
441

  
442
        if (refresh) {
443
            refresh();
444
        }
445
    }
446

  
447
    public Point getRectOrigin() {
448
        return rectOrigin;
449
    }
450

  
451
    public FLayoutDraw getLayoutDraw() {
452
        return layoutDraw;
453
    }
454

  
455
    public LayoutBehavior getCurrentLayoutTool() {
456
        return currentLayoutTool;
457
    }
458

  
459
    public Point getFirstPoint() {
460
        return m_FirstPoint;
461
    }
462

  
463
    public Point getPointAnt() {
464
        return m_PointAnt;
465
    }
466

  
467
    public Point getLastPoint() {
468
        return m_LastPoint;
469
    }
470

  
471
    public void setFirstPoint() {
472
        m_FirstPoint = position;
473
    }
474

  
475
    public void setPointAnt() {
476
        m_PointAnt = position;
477
    }
478

  
479
    public void setLastPoint() {
480
        m_LastPoint = position;
481
    }
482

  
483
    public void setPosition(Point point2) {
484
        if (layoutContext.isAdjustingToGrid()
485
            && getCurrentLayoutTool().isAdjustable()) {
486
            position =
487
                FLayoutUtilities.getPointGrid(point2, layoutContext
488
                    .getAttributes().getHGridGapCm(), layoutContext
489
                    .getAttributes().getVGridGapCm(), layoutContext.getAT());
490
        } else {
491
            position = point2;
492
        }
493
    }
494

  
495
    public Point getPosition() {
496
        return position;
497
    }
498

  
499
    public AffineTransform getAT() {
500
        return layoutContext.getAT();
501
    }
502

  
503
    public GeometryAdapter getGeometryAdapter() {
504
        return geometryAdapter;
505
    }
506

  
507
    public void delLastPoint() {
508
        getGeometryAdapter().delLastPoint();
509
    }
510

  
511
    public int addGeometryAdapterPoint() {
512
        return getGeometryAdapter().addPoint(
513
            FLayoutUtilities.toSheetPoint(getPosition(), getAT()));
514
    }
515

  
516
    public void setGeometryAdapterPoinPosition() {
517
        getGeometryAdapter().pointPosition(
518
            FLayoutUtilities.toSheetPoint(getPosition(), getAT()));
519
    }
520

  
521
    public void clearMouseImage() {
522
        setCursor(transparentCursor);
523
    }
524

  
525
    public void refresh() {
526
        setStatus(DESACTUALIZADO);
527
        invalidate();
528
        repaint();
529
    }
530

  
531
    public synchronized boolean isDrawingCancelled() {
532
        return m_bCancelDrawing;
533
    }
534

  
535
    public synchronized void setCancelDrawing(boolean b) {
536
        m_bCancelDrawing = b;
537

  
538
        for (int i = 0; i < layoutContext.getFFrames().length; i++) {
539
            IFFrame fframe = layoutContext.getFFrame(i);
540

  
541
            if (fframe instanceof IFFrameUseFMap
542
                && (((IFFrameUseFMap) fframe).getMapContext() != null)) {
543
                // //TODO((FFrameView)
544
                // getFFrames().get(i)).getFMap().setCancelDrawing(b);
545
            }
546
        }
547
    }
548

  
549
    public Rectangle getReSel() {
550
        return reSel;
551
    }
552

  
553
    public boolean isReSel() {
554
        return isReSel;
555
    }
556

  
557
    public void setIsReSel(boolean b) {
558
        isReSel = b;
559
    }
560

  
561
    public void viewFull() throws ReadException {
562
        IFFrame[] fframes = layoutContext.getSelectedFFrames();
563

  
564
        for (int i = 0; i < fframes.length; i++) {
565
            if (fframes[i] instanceof IFFrameUseFMap) {
566
                IFFrameUseFMap fframe = (IFFrameUseFMap) fframes[i];
567

  
568
                if (fframe.getMapContext() != null) {
569
                    fframe.fullExtent();
570
                }
571

  
572
                fframe.refresh();
573
            }
574
        }
575

  
576
        refresh();
577
    }
578

  
579
    public FLayoutZooms getLayoutZooms() {
580
        return layoutZooms;
581
    }
582

  
583
    public FLayoutFunctions getLayoutFunctions() {
584
        return layoutFunctions;
585
    }
586

  
587
    public LayoutContext getLayoutContext() {
588
        return layoutContext;
589
    }
590

  
591
    public void setGeometryAdapter(GeometryAdapter adapter) {
592
        geometryAdapter = adapter;
593
    }
594

  
595
    public JComponent getComponent() {
596
        return this;
597
    }
598

  
599
    public void update(Observable observable, Object notification) {
600
       if ((notification != null) && (notification instanceof LayoutNotification)){
601
    	   LayoutNotification layoutNotification = (LayoutNotification)notification;
602
           if (LayoutNotification.LAYOUT_VALIDATED.equals(layoutNotification.getType())){
603
               status = ACTUALIZADO;
604
           }else if (LayoutNotification.LAYOUT_INVALIDATED.equals(layoutNotification.getType())){
605
               status = DESACTUALIZADO;
606
           }else if (LayoutNotification.LAYOUT_REFRESH.equals(layoutNotification.getType())){
607
               refresh();
608
           }
609
       }
610
    }
611
}
tags/org.gvsig.app.document.layout2.app-2.0.35/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/LayoutNotification.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

  
25

  
26
/**
27
 * @author gvSIG Team
28
 * @version $Id$
29
 *
30
 */
31
public interface LayoutNotification {
32
    /** Fired when the layout has to be repainted */
33
    public static final String LAYOUT_INVALIDATED = "layout_invalidated";
34

  
35
    /** Fired when the layout doesn't have to be repainted */
36
    public static final String LAYOUT_VALIDATED = "layout_validated";
37
    
38
    /** Fired when the layout doesn't have to be repainted */
39
    public static final String LAYOUT_REFRESH = "layout_refresh";
40
	
41
    /**
42
     * Returns the type of this notification, represented by one of the constants defined in this interface.
43
     * @return a String containing this notification's type
44
     */
45
    public String getType();
46
}
tags/org.gvsig.app.document.layout2.app-2.0.35/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/Attributes.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.Point2D;
25
import java.awt.geom.Rectangle2D;
26
import java.awt.print.PageFormat;
27
import java.awt.print.Paper;
28
import java.text.NumberFormat;
29
import java.util.ArrayList;
30

  
31
import javax.print.attribute.HashPrintRequestAttributeSet;
32
import javax.print.attribute.PrintRequestAttributeSet;
33
import javax.print.attribute.standard.Copies;
34
import javax.print.attribute.standard.Fidelity;
35
import javax.print.attribute.standard.Media;
36
import javax.print.attribute.standard.MediaPrintableArea;
37
import javax.print.attribute.standard.MediaSizeName;
38
import javax.print.attribute.standard.OrientationRequested;
39
import javax.print.attribute.standard.PrintQuality;
40
import javax.print.attribute.standard.Sides;
41

  
42
import org.gvsig.andami.PluginServices;
43
import org.gvsig.andami.PluginsLocator;
44
import org.gvsig.app.extension.LayoutExtension;
45
import org.gvsig.app.gui.preferencespage.PreferenceKeys;
46
import org.gvsig.compat.CompatLocator;
47
import org.gvsig.compat.print.PrintAttributes;
48
import org.gvsig.fmap.mapcontext.MapContext;
49
import org.gvsig.i18n.Messages;
50
import org.gvsig.tools.ToolsLocator;
51
import org.gvsig.tools.dynobject.DynStruct;
52
import org.gvsig.tools.persistence.PersistenceManager;
53
import org.gvsig.tools.persistence.Persistent;
54
import org.gvsig.tools.persistence.PersistentState;
55
import org.gvsig.tools.persistence.exception.PersistenceException;
56
import org.gvsig.utils.XMLEntity;
57
import org.slf4j.Logger;
58
import org.slf4j.LoggerFactory;
59

  
60
/**
61
 * Attributes of Layout.
62
 * 
63
 * @author Vicente Caballero Navarro
64
 * @author jldominguez
65
 */
66
public class Attributes implements Persistent {
67

  
68
    public static final String PERSISTENCE_DEFINITION_NAME = "Attributes";
69
    public static final String DPI_FIELD = "DPI";
70
    public static final String DPISCREEN_FIELD = "DPISCREEN";
71
    public static final String TYPEUNIT_FIELD = "typeUnit";
72
    public static final String NUMX_FIELD = "numX";
73
    public static final String NUMY_FIELD = "numY";
74
    public static final String UNITX_FIELD = "unitX";
75
    public static final String UNITY_FIELD = "unitY";
76
    public static final String HASMARGIN_FIELD = "hasMargin";
77
    public static final String RESOLUTIONSEL_FIELD = "resolutionSel";
78
    public static final String TYPESEL_FIELD = "typeSel";
79
    public static final String SELTYPEUNIT_FIELD = "selTypeUnit";
80
    public static final String SIZEPAPER_FIELD = "sizePaper";
81
    public static final String AREA_FIELD = "area";
82
    public static final String SIZEINUNITS_FIELD = "sizeInUnits";
83
    public static final String ISLANDSEL_FIELD = "isLandSel";
84
    public static final String DEGREES = "Grados";
85
    public static final int HIGH = 0;
86
    public static final int NORMAL = 1;
87
    public static final int DRAFT = 2;
88

  
89
    // Para impresi?n
90
    public final static double PULGADA = 2.54;
91

  
92
    public final static Size STANDARD_LETTER_PAPER_SIZE = new Size(8.5, 11.0);
93
    public final static Size STANDARD_FOLIO_PAPER_SIZE = new Size(8.5, 13.0);
94
    public final static Size STANDARD_LEGAL_PAPER_SIZE = new Size(8.5, 14.0);
95
    public final static Size STANDARD_TABLOID_PAPER_SIZE = new Size(11.0, 17.0);
96
    public final static Size METRIC_A0_PAPER_SIZE = new Size(118.9, 84.1);
97
    public final static Size METRIC_A1_PAPER_SIZE = new Size(84.1, 59.4);
98
    public final static Size METRIC_A2_PAPER_SIZE = new Size(59.4, 42.0);
99
    public final static Size METRIC_A3_PAPER_SIZE = new Size(42.0, 29.7);
100
    public final static Size METRIC_A4_PAPER_SIZE = new Size(29.7, 21.0);
101
    public final static Size METRIC_A5_PAPER_SIZE = new Size(21.0, 14.8);
102
    public final static Size ANSI_ENG_A_PAPER_SIZE = new Size(11.0, 8.5);
103
    public final static Size ANSI_ENG_B_PAPER_SIZE = new Size(17.0, 11.0);
104
    public final static Size ANSI_ENG_C_PAPER_SIZE = new Size(22.0, 17.0);
105
    public final static Size ANSI_ENG_D_PAPER_SIZE = new Size(34.0, 22.0);
106
    public final static Size ANSI_ENG_E_PAPER_SIZE = new Size(44.0, 34.0);
107
    public final static Size ANSI_ARCH_A_PAPER_SIZE = new Size(12.0, 9.0);
108
    public final static Size ANSI_ARCH_B_PAPER_SIZE = new Size(18.0, 12.0);
109
    public final static Size ANSI_ARCH_C_PAPER_SIZE = new Size(24.0, 18.0);
110
    public final static Size ANSI_ARCH_D_PAPER_SIZE = new Size(36.0, 24.0);
111
    public final static Size ANSI_ARCH_E_PAPER_SIZE = new Size(42.0, 30.0);
112
    
113
    /**
114
     * CUSTOM_PAPER_SIZE does not know about portrait/landscape
115
     * (same as other PAPER constants)
116
     */
117
    public static Size CUSTOM_PAPER_SIZE = new Size(100.0, 100.0);
118
    
119
    public final static int PRINT = 0;
120
    public final static int CUSTOM = 6;
121
    public final static int A0 = 5;
122
    public final static int A1 = 4;
123
    public final static int A2 = 3;
124
    public final static int A3 = 2;
125
    public final static int A4 = 1;
126
    public static int DPI = 300;
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff