Revision 770
tags/org.gvsig.app.document.layout2.app-2.0.120/org.gvsig.app.document.layout2.app.mainplugin/buildNumber.properties | ||
---|---|---|
1 |
#Mon Feb 19 13:43:32 CET 2018 |
|
2 |
buildNumber=139 |
tags/org.gvsig.app.document.layout2.app-2.0.120/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.120/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.120/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.120/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.120/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.120/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/FLayoutDraw.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.Component; |
|
26 |
import java.awt.Cursor; |
|
27 |
import java.awt.Graphics; |
|
28 |
import java.awt.Graphics2D; |
|
29 |
import java.awt.geom.AffineTransform; |
|
30 |
import java.awt.geom.Point2D; |
|
31 |
import java.awt.geom.Rectangle2D; |
|
32 |
import java.awt.image.BufferedImage; |
|
33 |
import java.awt.print.PageFormat; |
|
34 |
import java.awt.print.Printable; |
|
35 |
import java.awt.print.PrinterException; |
|
36 |
import java.io.BufferedOutputStream; |
|
37 |
import java.io.File; |
|
38 |
import java.io.FileOutputStream; |
|
39 |
import java.io.IOException; |
|
40 |
import java.io.OutputStream; |
|
41 |
|
|
42 |
import javax.print.Doc; |
|
43 |
import javax.print.DocFlavor; |
|
44 |
import javax.print.DocPrintJob; |
|
45 |
import javax.print.PrintException; |
|
46 |
import javax.print.SimpleDoc; |
|
47 |
import javax.print.StreamPrintService; |
|
48 |
import javax.print.StreamPrintServiceFactory; |
|
49 |
import javax.print.attribute.DocAttributeSet; |
|
50 |
import javax.print.attribute.HashDocAttributeSet; |
|
51 |
import javax.print.attribute.PrintRequestAttributeSet; |
|
52 |
import javax.swing.JOptionPane; |
|
53 |
|
|
54 |
import com.lowagie.text.Document; |
|
55 |
import com.lowagie.text.DocumentException; |
|
56 |
import com.lowagie.text.PageSize; |
|
57 |
import com.lowagie.text.Rectangle; |
|
58 |
import com.lowagie.text.pdf.PdfContentByte; |
|
59 |
import com.lowagie.text.pdf.PdfWriter; |
|
60 |
|
|
61 |
import org.slf4j.Logger; |
|
62 |
import org.slf4j.LoggerFactory; |
|
63 |
import org.gvsig.andami.PluginServices; |
|
64 |
import org.gvsig.app.project.documents.layout.fframes.IFFrame; |
|
65 |
import org.gvsig.app.project.documents.layout.gui.LayoutPanel; |
|
66 |
import org.gvsig.fmap.dal.exception.ReadException; |
|
67 |
import org.gvsig.tools.observer.Observable; |
|
68 |
import org.gvsig.tools.observer.ObservableHelper; |
|
69 |
import org.gvsig.tools.observer.Observer; |
|
70 |
|
|
71 |
/** |
|
72 |
* Clase que implementa los m?todos del Layout que dibujan sobre el Graphics. |
|
73 |
* |
|
74 |
* @author Vicente Caballero Navarro |
|
75 |
*/ |
|
76 |
public class FLayoutDraw implements Observable, Printable{ |
|
77 |
private static final Logger LOG = |
|
78 |
LoggerFactory.getLogger(FLayoutDraw.class); |
|
79 |
|
|
80 |
private LayoutPanel layoutPanel; |
|
81 |
private LayoutControl layoutControl; |
|
82 |
private LayoutContext layoutContext; |
|
83 |
private ObservableHelper observers; |
|
84 |
|
|
85 |
/** |
|
86 |
* Crea un nuevo FLayoutDraw. |
|
87 |
* |
|
88 |
* @param l |
|
89 |
* Referencia al Layout. |
|
90 |
*/ |
|
91 |
public FLayoutDraw(LayoutPanel layoutPanel) { |
|
92 |
this.layoutPanel = layoutPanel; |
|
93 |
observers = new ObservableHelper(); |
|
94 |
observers.addObserver(layoutPanel.getLayoutControl()); |
|
95 |
} |
|
96 |
|
|
97 |
public void initialize(){ |
|
98 |
if ((layoutContext == null) || (layoutControl == null)){ |
|
99 |
this.layoutControl = layoutPanel.getLayoutControl(); |
|
100 |
this.layoutContext = layoutPanel.getLayoutContext(); |
|
101 |
} |
|
102 |
} |
|
103 |
|
|
104 |
/** |
|
105 |
* M?todo para dibujar el Layout y modificar la matriz de transformaci?n a |
|
106 |
* partir del tama?o en pixels que tenga rect y el formato de papel |
|
107 |
* seleccionado. |
|
108 |
* |
|
109 |
* @param g2 |
|
110 |
* @param imgBase |
|
111 |
* Si es null, est?s imprimiendo. Si no, la usas para el |
|
112 |
* c?digo de optimizaci?n. |
|
113 |
* |
|
114 |
* @throws ReadDriverException |
|
115 |
*/ |
|
116 |
public void drawLayout(Graphics2D g2, BufferedImage imgBase) |
|
117 |
throws ReadException { |
|
118 |
if (!initializeAffineTransform()) { |
|
119 |
return; |
|
120 |
} |
|
121 |
|
|
122 |
IFFrame[] fframes = layoutContext.getFFrames(); |
|
123 |
for (int i = 0; i < fframes.length; i++) { |
|
124 |
IFFrame f = fframes[i]; |
|
125 |
f.draw(g2, layoutContext.getAT(), layoutControl.getComponent().getVisibleRect(), |
|
126 |
imgBase); |
|
127 |
|
|
128 |
// Dibuja el s?mbolo de que contiene un tag. |
|
129 |
if ((f.getTag() != null) && (layoutPanel.isShowIconTag())) { |
|
130 |
f.drawSymbolTag(g2); |
|
131 |
} |
|
132 |
} |
|
133 |
|
|
134 |
if (!(fframes.length == 0)) { |
|
135 |
observers.notifyObservers(this, |
|
136 |
new DefaultLayoutNotification(LayoutNotification.LAYOUT_VALIDATED)); |
|
137 |
} else { |
|
138 |
observers.notifyObservers(this, |
|
139 |
new DefaultLayoutNotification(LayoutNotification.LAYOUT_INVALIDATED)); |
|
140 |
} |
|
141 |
} |
|
142 |
|
|
143 |
public boolean initializeAffineTransform(){ |
|
144 |
initialize(); |
|
145 |
AffineTransform at = layoutContext.getAT(); |
|
146 |
Rectangle2D rLayout = layoutControl.getRect(); |
|
147 |
if (rLayout.getHeight()<0) { |
|
148 |
// still not ready to be painted |
|
149 |
return false; |
|
150 |
} |
|
151 |
Attributes attributes = layoutContext.getAttributes(); |
|
152 |
|
|
153 |
layoutControl.setCancelDrawing(false); |
|
154 |
|
|
155 |
double scale = 0; |
|
156 |
scale = rLayout.getHeight() / attributes.getPaperSize().getHeight() * 1; // paper (paper units) to screen (pixels) scale |
|
157 |
AffineTransform escalado = new AffineTransform(); |
|
158 |
AffineTransform translacion = new AffineTransform(); |
|
159 |
translacion.setToTranslation(rLayout.getMinX(), rLayout.getMinY()); |
|
160 |
escalado.setToScale(scale, scale); |
|
161 |
at.setToIdentity(); |
|
162 |
at.concatenate(translacion); |
|
163 |
at.concatenate(escalado); |
|
164 |
attributes.calculateGridGapX(rLayout); |
|
165 |
attributes.calculateGridGapY(rLayout); |
|
166 |
return true; |
|
167 |
} |
|
168 |
|
|
169 |
/** |
|
170 |
* Dibuja sobre un Graphics2D el rect?ngulo que representa al folio. |
|
171 |
* |
|
172 |
* @param g |
|
173 |
* Graphics2D |
|
174 |
*/ |
|
175 |
public void drawRectangle(Graphics2D g) { |
|
176 |
initialize(); |
|
177 |
Attributes attributes = layoutContext.getAttributes(); |
|
178 |
Rectangle2D rLayout = layoutControl.getRect(); |
|
179 |
AffineTransform at = layoutContext.getAT(); |
|
180 |
|
|
181 |
double unidadesX = attributes.getHGridGapCm(); |
|
182 |
double unidadesY = attributes.getVGridGapCm(); |
|
183 |
|
|
184 |
if ((unidadesX == 0) && (unidadesY == 0)) { |
|
185 |
return; |
|
186 |
} |
|
187 |
|
|
188 |
g.setColor(Color.darkGray); |
|
189 |
|
|
190 |
Rectangle2D.Double rectBig = |
|
191 |
new Rectangle2D.Double(rLayout.getX(), rLayout.getY(), |
|
192 |
rLayout.getWidth(), rLayout.getHeight()); |
|
193 |
|
|
194 |
g.fillRect((int) rectBig.x + 7, (int) rectBig.y + 7, |
|
195 |
(int) rectBig.width, (int) rectBig.height); |
|
196 |
|
|
197 |
Rectangle2D.Double r = new Rectangle2D.Double(); |
|
198 |
|
|
199 |
if (attributes.isMargin()) { |
|
200 |
|
|
201 |
r = |
|
202 |
new Rectangle2D.Double( |
|
203 |
(rLayout.getX() + FLayoutUtilities.fromSheetDistance( |
|
204 |
attributes.getAreaInsets()[2], at)), |
|
205 |
(rLayout.getY() + FLayoutUtilities.fromSheetDistance( |
|
206 |
attributes.getAreaInsets()[0], at)), |
|
207 |
(rLayout.getWidth() - FLayoutUtilities.fromSheetDistance( |
|
208 |
attributes.getAreaInsets()[2] + attributes.getAreaInsets()[3], at)), |
|
209 |
(rLayout.getHeight() - FLayoutUtilities.fromSheetDistance( |
|
210 |
attributes.getAreaInsets()[0] + attributes.getAreaInsets()[1], at))); |
|
211 |
} else { |
|
212 |
r.setRect(rLayout); |
|
213 |
} |
|
214 |
|
|
215 |
g.setColor(Color.white); |
|
216 |
g.fill(rLayout); |
|
217 |
|
|
218 |
g.setColor(Color.darkGray); |
|
219 |
g.drawRect((int) rLayout.getMinX(), (int) rLayout.getMinY(), |
|
220 |
(int) rLayout.getWidth(), (int) rLayout.getHeight()); |
|
221 |
|
|
222 |
if (attributes.isMargin()) { |
|
223 |
g.setColor(Color.black); |
|
224 |
|
|
225 |
g.drawRect((int) r.x, (int) r.y, (int) r.width, (int) r.height); |
|
226 |
} |
|
227 |
} |
|
228 |
|
|
229 |
/** |
|
230 |
* DOCUMENT ME! |
|
231 |
* |
|
232 |
* @param g |
|
233 |
* DOCUMENT ME! |
|
234 |
*/ |
|
235 |
public void drawGrid(Graphics2D g) { |
|
236 |
int unidadesMin = 6; |
|
237 |
Attributes attributes = layoutContext.getAttributes(); |
|
238 |
Rectangle2D rLayout = layoutControl.getRect(); |
|
239 |
AffineTransform at = layoutContext.getAT(); |
|
240 |
|
|
241 |
double unidadesX = attributes.getHGridGapPx(); |
|
242 |
double unidadesY = attributes.getVGridGapPx(); |
|
243 |
|
|
244 |
Rectangle2D.Double r = new Rectangle2D.Double(); |
|
245 |
|
|
246 |
if (attributes.isMargin()) { |
|
247 |
r = |
|
248 |
new Rectangle2D.Double( |
|
249 |
(rLayout.getX() + FLayoutUtilities.fromSheetDistance( |
|
250 |
attributes.getAreaInsets()[2], at)), |
|
251 |
(rLayout.getY() + FLayoutUtilities.fromSheetDistance( |
|
252 |
attributes.getAreaInsets()[0], at)), |
|
253 |
(rLayout.getWidth() - FLayoutUtilities.fromSheetDistance( |
|
254 |
attributes.getAreaInsets()[2] + attributes.getAreaInsets()[3], at)), |
|
255 |
(rLayout.getHeight() - FLayoutUtilities.fromSheetDistance( |
|
256 |
attributes.getAreaInsets()[0] + attributes.getAreaInsets()[1], at))); |
|
257 |
} else { |
|
258 |
r.setRect(rLayout); |
|
259 |
} |
|
260 |
if ((unidadesX == 0) && (unidadesY == 0)) { |
|
261 |
return; |
|
262 |
} |
|
263 |
g.setColor(Color.darkGray); |
|
264 |
|
|
265 |
if (((unidadesX > unidadesMin) || (unidadesY > unidadesMin)) |
|
266 |
&& layoutContext.isGridVisible()) { |
|
267 |
double ax = r.getMinX(); |
|
268 |
double ay; |
|
269 |
|
|
270 |
while (ax < (r.getMaxX())) { |
|
271 |
ay = (r.getMinY()); |
|
272 |
|
|
273 |
while (ay < (r.getMaxY())) { |
|
274 |
g.drawLine((int) ax, (int) ay, (int) ax, (int) ay); |
|
275 |
ay = ay + unidadesY; |
|
276 |
} |
|
277 |
|
|
278 |
ax = ax + unidadesX; |
|
279 |
} |
|
280 |
} |
|
281 |
} |
|
282 |
|
|
283 |
/** |
|
284 |
* Dibuja sobre el graphics2d las reglas. |
|
285 |
* |
|
286 |
* @param g |
|
287 |
* graphics2d sobre el que se dibuja. |
|
288 |
* @param color |
|
289 |
* Color de la regla. |
|
290 |
*/ |
|
291 |
public void drawRuler(Graphics2D g, Color color) { |
|
292 |
Attributes attributes = layoutContext.getAttributes(); |
|
293 |
Rectangle2D rLayout = layoutControl.getRect(); |
|
294 |
AffineTransform at = layoutContext.getAT(); |
|
295 |
|
|
296 |
if (layoutContext.getRuler()) { |
|
297 |
int ini = 10; |
|
298 |
int w = 30; |
|
299 |
int wi = 16; |
|
300 |
|
|
301 |
g.setColor(new Color(250, 255, 250, 180)); |
|
302 |
g.fillRect(ini, w, wi, layoutControl.getComponent().getHeight() - w); |
|
303 |
g.fillRect(w, ini, layoutControl.getWidth() - w, wi); |
|
304 |
|
|
305 |
g.setColor(new Color(100, 155, 150, 180)); |
|
306 |
g.fillRect(w, ini, (int) rLayout.getX() - w, wi); |
|
307 |
g.fillRect((int) rLayout.getMaxX(), ini, layoutControl.getWidth() |
|
308 |
- (int) rLayout.getMaxX(), wi); |
|
309 |
|
|
310 |
g.fillRect(ini, w, wi, (int) rLayout.getY() - w); |
|
311 |
g.fillRect(ini, (int) rLayout.getMaxY(), wi, |
|
312 |
layoutControl.getHeight() - (int) rLayout.getMaxY()); |
|
313 |
|
|
314 |
if (attributes.isMargin()) { |
|
315 |
g.setColor(new Color(50, 55, 50, 180)); |
|
316 |
g.fillRect((int) rLayout.getX(), ini, (int) FLayoutUtilities |
|
317 |
.fromSheetDistance(attributes.getAreaInsets()[2], at), wi); |
|
318 |
g.fillRect( |
|
319 |
(int) rLayout.getMaxX() |
|
320 |
- (int) FLayoutUtilities.fromSheetDistance( |
|
321 |
attributes.getAreaInsets()[3], at), ini, |
|
322 |
(int) FLayoutUtilities.fromSheetDistance( |
|
323 |
attributes.getAreaInsets()[3], at), wi); |
|
324 |
|
|
325 |
g.fillRect(ini, (int) rLayout.getY(), wi, |
|
326 |
(int) FLayoutUtilities.fromSheetDistance( |
|
327 |
attributes.getAreaInsets()[0], at)); |
|
328 |
g.fillRect( |
|
329 |
ini, |
|
330 |
(int) rLayout.getMaxY() |
|
331 |
- (int) FLayoutUtilities.fromSheetDistance( |
|
332 |
attributes.getAreaInsets()[1], at), wi, |
|
333 |
(int) FLayoutUtilities.fromSheetDistance( |
|
334 |
attributes.getAreaInsets()[1], at)); |
|
335 |
} |
|
336 |
|
|
337 |
g.setColor(color); |
|
338 |
g.drawLine(w, wi + ini, layoutControl.getWidth(), wi + ini); |
|
339 |
g.drawLine(w, ini, layoutControl.getWidth(), ini); |
|
340 |
g.drawLine(ini, w, ini, layoutControl.getHeight()); |
|
341 |
g.drawLine(wi + ini, w, wi + ini, layoutControl.getHeight()); |
|
342 |
|
|
343 |
drawLineY(g, 5, 12, 22, rLayout.getY(), 0); |
|
344 |
drawLineX(g, 5, 12, 22, rLayout.getX(), 0); |
|
345 |
|
|
346 |
if (FLayoutUtilities.fromSheetDistance(1, at) > 15) { |
|
347 |
drawLineY(g, 1, 12, 22, rLayout.getY(), 0); |
|
348 |
drawLineX(g, 1, 12, 22, rLayout.getX(), 0); |
|
349 |
|
|
350 |
if (FLayoutUtilities.fromSheetDistance(1, at) > 25) { |
|
351 |
drawLineY(g, 1, 18, 22, rLayout.getY(), 0.5); |
|
352 |
drawLineY(g, 0.1, 21, 22, rLayout.getY(), 0); |
|
353 |
drawLineX(g, 1, 18, 22, rLayout.getX(), 0.5); |
|
354 |
drawLineX(g, 0.1, 21, 22, rLayout.getX(), 0); |
|
355 |
} |
|
356 |
} |
|
357 |
} |
|
358 |
} |
|
359 |
|
|
360 |
/** |
|
361 |
* Dibuja sobre el graphics2d las l?neas verticales que representan a las |
|
362 |
* unidades de medida. |
|
363 |
* |
|
364 |
* @param g |
|
365 |
* Graphics2d sobre el que se dibuja. |
|
366 |
* @param dist |
|
367 |
* distancia en cent?metros de una l?nea a otra. |
|
368 |
* @param init |
|
369 |
* inicio de la l?nea. |
|
370 |
* @param end |
|
371 |
* fin de la l?nea. |
|
372 |
* @param y |
|
373 |
* rect?ngulo, dentro del cual se dibujan las l?neas. |
|
374 |
* @param desp |
|
375 |
* Desplazamiento. |
|
376 |
*/ |
|
377 |
private void drawLineY(Graphics2D g, double dist, int init, int end, |
|
378 |
double y, double desp) { |
|
379 |
initialize(); |
|
380 |
AffineTransform at = layoutContext.getAT(); |
|
381 |
|
|
382 |
double distY = FLayoutUtilities.fromSheetDistance(dist, at); |
|
383 |
double rota = Math.toRadians(90); |
|
384 |
|
|
385 |
if (distY > 4) { |
|
386 |
double despY = FLayoutUtilities.fromSheetDistance(desp, at); |
|
387 |
|
|
388 |
double posUnitY = y + despY; |
|
389 |
double posUnitYNeg = posUnitY; |
|
390 |
int num = 0; |
|
391 |
double iniY = 40; |
|
392 |
Point2D.Double pfin = |
|
393 |
FLayoutUtilities.fromSheetPoint(new Point2D.Double( |
|
394 |
layoutControl.getWidth(), layoutControl.getHeight()), at); |
|
395 |
|
|
396 |
while (posUnitY < (pfin.y - 5)) { |
|
397 |
posUnitYNeg -= distY; |
|
398 |
|
|
399 |
if (distY > 16) { |
|
400 |
if (init == 12) { |
|
401 |
if (posUnitY > iniY) { |
|
402 |
g.rotate(-rota, 20, posUnitY - 12); |
|
403 |
g.drawString(String.valueOf(num), 10, |
|
404 |
(int) posUnitY - 12); |
|
405 |
g.rotate(rota, 20, posUnitY - 12); |
|
406 |
} |
|
407 |
|
|
408 |
if (dist == 5) { |
|
409 |
num = num + 5; |
|
410 |
} else { |
|
411 |
num++; |
|
412 |
} |
|
413 |
|
|
414 |
if (posUnitYNeg > iniY) { |
|
415 |
g.rotate(-rota, 20, posUnitYNeg - 12); |
|
416 |
g.drawString(String.valueOf(-num), 10, |
|
417 |
(int) posUnitYNeg - 12); |
|
418 |
g.rotate(rota, 20, posUnitYNeg - 12); |
|
419 |
} |
|
420 |
} |
|
421 |
} |
|
422 |
|
|
423 |
if (posUnitY > iniY) { |
|
424 |
g.drawLine(2 + init, (int) posUnitY, 2 + end, |
|
425 |
(int) posUnitY); |
|
426 |
} |
|
427 |
|
|
428 |
if (posUnitYNeg > iniY) { |
|
429 |
g.drawLine(2 + init, (int) posUnitYNeg, 2 + end, |
|
430 |
(int) posUnitYNeg); |
|
431 |
} |
|
432 |
|
|
433 |
posUnitY += distY; |
|
434 |
} |
|
435 |
} |
|
436 |
} |
|
437 |
|
|
438 |
/** |
|
439 |
* Dibuja sobre el graphics2d las l?neas horizontales que representan a las |
|
440 |
* unidades de medida. |
|
441 |
* |
|
442 |
* @param g |
|
443 |
* Graphics2d sobre el que se dibuja. |
|
444 |
* @param dist |
|
445 |
* distancia en cent?metros de una l?nea a otra. |
|
446 |
* @param init |
|
447 |
* inicio de la l?nea. |
|
448 |
* @param end |
|
449 |
* fin de la l?nea. |
|
450 |
* @param x |
|
451 |
* rect?ngulo, dentro del cual se dibujan las l?neas. |
|
452 |
* @param desp |
|
453 |
* Desplazamiento. |
|
454 |
*/ |
|
455 |
private void drawLineX(Graphics2D g, double dist, int init, int end, |
|
456 |
double x, double desp) { |
|
457 |
initialize(); |
|
458 |
AffineTransform at = layoutContext.getAT(); |
|
459 |
|
|
460 |
double distX = FLayoutUtilities.fromSheetDistance(dist, at); |
|
461 |
|
|
462 |
if (distX > 4) { |
|
463 |
double despX = FLayoutUtilities.fromSheetDistance(desp, at); |
|
464 |
double posUnitX = x + despX; |
|
465 |
double posUnitXNeg = posUnitX; |
|
466 |
int num = 0; |
|
467 |
double iniX = 40; |
|
468 |
Point2D.Double pfin = |
|
469 |
FLayoutUtilities.fromSheetPoint(new Point2D.Double( |
|
470 |
layoutControl.getWidth(), layoutControl.getHeight()), at); |
|
471 |
|
|
472 |
while (posUnitX < (pfin.x - 5)) { |
|
473 |
posUnitXNeg -= distX; |
|
474 |
|
|
475 |
if (init == 12) { |
|
476 |
if (distX > 16) { |
|
477 |
if (posUnitX > iniX) { |
|
478 |
g.drawString(String.valueOf(num), |
|
479 |
(int) posUnitX + 3, 20); |
|
480 |
} |
|
481 |
|
|
482 |
if (dist == 5) { |
|
483 |
num = num + 5; |
|
484 |
} else { |
|
485 |
num++; |
|
486 |
} |
|
487 |
|
|
488 |
if (posUnitXNeg > iniX) { |
|
489 |
g.drawString(String.valueOf(-num), |
|
490 |
(int) posUnitXNeg + 3, 20); |
|
491 |
} |
|
492 |
} |
|
493 |
} |
|
494 |
|
|
495 |
if (posUnitX > iniX) { |
|
496 |
g.drawLine((int) posUnitX, 2 + init, (int) posUnitX, |
|
497 |
2 + end); |
|
498 |
} |
|
499 |
|
|
500 |
if (posUnitXNeg > iniX) { |
|
501 |
g.drawLine((int) posUnitXNeg, 2 + init, (int) posUnitXNeg, |
|
502 |
2 + end); |
|
503 |
} |
|
504 |
|
|
505 |
posUnitX += distX; |
|
506 |
} |
|
507 |
} |
|
508 |
} |
|
509 |
|
|
510 |
/** |
|
511 |
* Dibuja los handlers sobre los fframes que esten seleccionados. |
|
512 |
* |
|
513 |
* @param g |
|
514 |
* Graphics sobre el que se dibuja. |
|
515 |
* @param color |
|
516 |
* Color de los Handlers. |
|
517 |
*/ |
|
518 |
public void drawHandlers(Graphics2D g, Color color) { |
|
519 |
initialize(); |
|
520 |
|
|
521 |
g.setColor(color); |
|
522 |
IFFrame[] fframes = layoutContext.getFFrames(); |
|
523 |
for (int i = 0; i < fframes.length; i++) { |
|
524 |
IFFrame fframe = fframes[i]; |
|
525 |
|
|
526 |
if (fframe.getSelected() != IFFrame.NOSELECT) { |
|
527 |
fframe.drawHandlers(g); |
|
528 |
} |
|
529 |
} |
|
530 |
} |
|
531 |
|
|
532 |
/** |
|
533 |
* A partir de un fichero que se pasa como par?metro se crea un ps con el |
|
534 |
* contenido del Layout. |
|
535 |
* |
|
536 |
* @param ps |
|
537 |
*/ |
|
538 |
public void toPS(File ps) { |
|
539 |
initialize(); |
|
540 |
Attributes attributes = layoutContext.getAttributes(); |
|
541 |
|
|
542 |
try { |
|
543 |
// Prepare the output file to receive the postscript |
|
544 |
OutputStream fos = |
|
545 |
new BufferedOutputStream(new FileOutputStream(ps)); |
|
546 |
|
|
547 |
// Find a factory that can do the conversion |
|
548 |
// DocFlavor flavor = DocFlavor.INPUT_STREAM.GIF; |
|
549 |
DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE; |
|
550 |
StreamPrintServiceFactory[] factories = |
|
551 |
StreamPrintServiceFactory.lookupStreamPrintServiceFactories( |
|
552 |
flavor, "application/postscript"); |
|
553 |
|
|
554 |
if (factories.length > 0) { |
|
555 |
StreamPrintService service = factories[0].getPrintService(fos); |
|
556 |
|
|
557 |
// Create the print job |
|
558 |
DocPrintJob job = service.createPrintJob(); |
|
559 |
Doc doc = new SimpleDoc(this, flavor, null); |
|
560 |
// Doc doc = new SimpleDoc(is, flavor, null); |
|
561 |
// Monitor print job events; for the implementation of |
|
562 |
// PrintJobWatcher, |
|
563 |
// see e702 Determining When a Print Job Has Finished |
|
564 |
// PrintJobWatcher pjDone = new PrintJobWatcher(job); |
|
565 |
// Actualizar attributes |
|
566 |
PrintRequestAttributeSet att = |
|
567 |
attributes.toPrintRequestAttributeSet(); |
|
568 |
// Print it |
|
569 |
job.print(doc, att); |
|
570 |
|
|
571 |
// Wait for the print job to be done |
|
572 |
// pjDone.waitForDone(); |
|
573 |
// It is now safe to close the streams |
|
574 |
} |
|
575 |
|
|
576 |
// is.close(); |
|
577 |
fos.close(); |
|
578 |
} catch (PrintException e) { |
|
579 |
LOG.error("Error printing the map", e); |
|
580 |
} catch (IOException e) { |
|
581 |
LOG.error("Error printing the map", e); |
|
582 |
} |
|
583 |
/* |
|
584 |
* PrintService defaultPrintService = |
|
585 |
* PrintServiceLookup.lookupDefaultPrintService(); |
|
586 |
* DocPrintJob printerJob = defaultPrintService.createPrintJob(); |
|
587 |
* |
|
588 |
* try { |
|
589 |
* DocFlavor flavor=DocFlavor.URL.POSTSCRIPT; |
|
590 |
* if (!defaultPrintService.isDocFlavorSupported(flavor)) { |
|
591 |
* System.err.println( |
|
592 |
* "The printer does not support the appropriate DocFlavor"); |
|
593 |
* }else { |
|
594 |
* |
|
595 |
* SimpleDoc simpleDoc; |
|
596 |
* simpleDoc = new SimpleDoc(ps.toURL(),flavor, null); |
|
597 |
* printerJob.print(simpleDoc, null); |
|
598 |
* } |
|
599 |
* } catch (MalformedURLException e) { |
|
600 |
* // TODO Auto-generated catch block |
|
601 |
* e.printStackTrace(); |
|
602 |
* } catch (PrintException e) { |
|
603 |
* // TODO Auto-generated catch block |
|
604 |
* e.printStackTrace(); |
|
605 |
* } |
|
606 |
*/ |
|
607 |
layoutControl.fullRect(); |
|
608 |
} |
|
609 |
|
|
610 |
/** |
|
611 |
* A partir de un fichero que se pasa como par?metro se crea un pdf con el |
|
612 |
* contenido del Layout. |
|
613 |
* |
|
614 |
* @param pdf |
|
615 |
*/ |
|
616 |
public void toPDF(File pdf) { |
|
617 |
Attributes attributes = layoutContext.getAttributes(); |
|
618 |
|
|
619 |
double w = ((attributes.getPaperSize().getWidth() * Attributes.DPISCREEN) / Attributes.PULGADA); |
|
620 |
double h = ((attributes.getPaperSize().getHeight() * Attributes.DPISCREEN) / Attributes.PULGADA); |
|
621 |
Rectangle pageSize = new com.lowagie.text.Rectangle((float) w, (float) h); |
|
622 |
Document document = new Document(pageSize); |
|
623 |
|
|
624 |
try { |
|
625 |
FileOutputStream fos = new FileOutputStream(pdf); |
|
626 |
PdfWriter writer = PdfWriter.getInstance(document, fos); |
|
627 |
document.open(); |
|
628 |
|
|
629 |
PdfContentByte cb = writer.getDirectContent(); |
|
630 |
Graphics2D g2 = cb.createGraphicsShapes((float) w, (float) h); |
|
631 |
|
|
632 |
try { |
|
633 |
print(g2, new PageFormat(), 0); |
|
634 |
} catch (PrinterException e) { |
|
635 |
LOG.error("Error printing the map", e); |
|
636 |
} |
|
637 |
g2.dispose(); |
|
638 |
|
|
639 |
} catch (DocumentException de) { |
|
640 |
LOG.error("Error printing the map", de); |
|
641 |
} catch (IOException ioe) { |
|
642 |
JOptionPane.showMessageDialog( |
|
643 |
(Component) PluginServices.getMainFrame(), ioe.getMessage()); |
|
644 |
} |
|
645 |
|
|
646 |
document.close(); |
|
647 |
|
|
648 |
layoutControl.fullRect(); |
|
649 |
} |
|
650 |
|
|
651 |
public int print(Graphics g, PageFormat format, int pi) |
|
652 |
throws PrinterException { |
|
653 |
initialize(); |
|
654 |
if (pi >= 1) { |
|
655 |
return Printable.NO_SUCH_PAGE; |
|
656 |
} |
|
657 |
|
|
658 |
Graphics2D g2d = (Graphics2D) g; |
|
659 |
|
|
660 |
AffineTransform at = g2d.getTransform(); |
|
661 |
g2d.translate(0, 0); |
|
662 |
layoutPanel.obtainRect(true); |
|
663 |
|
|
664 |
g2d.scale((double) 72 / (double) (Attributes.DPI), (double) 72 |
|
665 |
/ (double) (Attributes.DPI)); |
|
666 |
|
|
667 |
if (layoutContext.getAttributes().isMargin()) { |
|
668 |
g2d.setClip( |
|
669 |
(int) (layoutControl.getRect().getMinX() + FLayoutUtilities.fromSheetDistance( |
|
670 |
layoutContext.getAttributes().getAreaInsets()[2], layoutControl.getAT())), |
|
671 |
(int) (layoutPanel.getLayoutControl().getRect().getMinY() + FLayoutUtilities.fromSheetDistance( |
|
672 |
layoutContext.getAttributes().getAreaInsets()[0], layoutControl.getAT())), |
|
673 |
(int) (layoutControl.getRect().getWidth() - FLayoutUtilities.fromSheetDistance( |
|
674 |
layoutContext.getAttributes().getAreaInsets()[2] + layoutContext.getAttributes().getAreaInsets()[3], layoutControl.getAT())), |
|
675 |
(int) (layoutPanel.getLayoutControl().getRect().getHeight() - FLayoutUtilities.fromSheetDistance( |
|
676 |
layoutContext.getAttributes().getAreaInsets()[0] + layoutContext.getAttributes().getAreaInsets()[1], layoutControl.getAT()))); |
|
677 |
} |
|
678 |
drawShapes(g2d); |
|
679 |
g2d.setTransform(at); |
|
680 |
return Printable.PAGE_EXISTS; |
|
681 |
} |
|
682 |
|
|
683 |
/** |
|
684 |
* Se dibuja sobre el graphics el Layout. |
|
685 |
* |
|
686 |
* @param g2 |
|
687 |
* graphics sobre el que se dibuja. |
|
688 |
*/ |
|
689 |
public void drawShapes(Graphics2D g2) { |
|
690 |
initialize(); |
|
691 |
layoutPanel.setCursor(Cursor.getDefaultCursor()); |
|
692 |
if (!initializeAffineTransform()) { |
|
693 |
return; |
|
694 |
} |
|
695 |
|
|
696 |
IFFrame[] fframes = layoutContext.getFFrames(); |
|
697 |
for (int i = 0; i < fframes.length; i++) { |
|
698 |
fframes[i].print(g2, layoutControl.getAT(), null, layoutContext |
|
699 |
.getAttributes().toPrintAttributes()); |
|
700 |
} |
|
701 |
} |
|
702 |
|
|
703 |
public void addObserver(Observer o) { |
|
704 |
observers.addObserver(o); |
|
705 |
} |
|
706 |
|
|
707 |
public void deleteObserver(Observer o) { |
|
708 |
observers.deleteObserver(o); |
|
709 |
} |
|
710 |
|
|
711 |
public void deleteObservers() { |
|
712 |
observers.deleteObservers(); |
|
713 |
} |
|
714 |
} |
tags/org.gvsig.app.document.layout2.app-2.0.120/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/LayoutEvents.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.event.ActionEvent; |
|
25 |
import java.awt.event.ActionListener; |
|
26 |
import java.awt.event.ComponentEvent; |
|
27 |
import java.awt.event.ComponentListener; |
|
28 |
import java.awt.event.MouseEvent; |
|
29 |
import java.awt.event.MouseListener; |
|
30 |
import java.awt.event.MouseMotionListener; |
|
31 |
|
|
32 |
import org.gvsig.app.project.documents.layout.gui.FPopupMenu; |
|
33 |
import org.gvsig.app.project.documents.layout.gui.LayoutPanel; |
|
34 |
import org.gvsig.fmap.mapcontrol.tools.BehaviorException; |
|
35 |
import org.gvsig.utils.exceptionHandling.ExceptionHandlingSupport; |
|
36 |
import org.gvsig.utils.exceptionHandling.ExceptionListener; |
|
37 |
|
|
38 |
/** |
|
39 |
* Eventos que se realizan sobre el Layout. |
|
40 |
* |
|
41 |
* @author Vicente Caballero Navarro |
|
42 |
*/ |
|
43 |
public class LayoutEvents implements ActionListener, ComponentListener, |
|
44 |
MouseMotionListener, MouseListener { |
|
45 |
|
|
46 |
private LayoutPanel layout = null; |
|
47 |
private ExceptionHandlingSupport exceptionHandlingSupport = |
|
48 |
new ExceptionHandlingSupport(); |
|
49 |
|
|
50 |
/** |
|
51 |
* Crea un nuevo EventsHandler. |
|
52 |
* |
|
53 |
* @param l |
|
54 |
* Referencia al Layout. |
|
55 |
*/ |
|
56 |
public LayoutEvents(LayoutPanel l) { |
|
57 |
layout = l; |
|
58 |
} |
|
59 |
|
|
60 |
/** |
|
61 |
* @see java.awt.event.ComponentListener#componentHidden(java.awt.event.ComponentEvent) |
|
62 |
*/ |
|
63 |
public void componentHidden(ComponentEvent arg0) { |
|
64 |
} |
|
65 |
|
|
66 |
/** |
|
67 |
* @see java.awt.event.ComponentListener#componentMoved(java.awt.event.ComponentEvent) |
|
68 |
*/ |
|
69 |
public void componentMoved(ComponentEvent arg0) { |
|
70 |
} |
|
71 |
|
|
72 |
/** |
|
73 |
* @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent) |
|
74 |
*/ |
|
75 |
public void componentResized(ComponentEvent arg0) { |
|
76 |
// layout.getLayoutControl().fullRect(); |
|
77 |
layout.getLayoutControl().refresh(); |
|
78 |
} |
|
79 |
|
|
80 |
/** |
|
81 |
* @see java.awt.event.ComponentListener#componentShown(java.awt.event.ComponentEvent) |
|
82 |
*/ |
|
83 |
public void componentShown(ComponentEvent arg0) { |
|
84 |
} |
|
85 |
|
|
86 |
/** |
|
87 |
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) |
|
88 |
*/ |
|
89 |
public void actionPerformed(ActionEvent arg0) { |
|
90 |
layout.repaint(); |
|
91 |
} |
|
92 |
|
|
93 |
/** |
|
94 |
* @see java.awt.event.MouseMotionListener#mouseDragged(java.awt.event.MouseEvent) |
|
95 |
*/ |
|
96 |
public void mouseDragged(MouseEvent e) { |
|
97 |
if (e.getButton() != MouseEvent.BUTTON3) { |
|
98 |
layout.getLayoutControl().setLastPoint(); |
|
99 |
layout.repaint(); |
|
100 |
} |
|
101 |
try { |
|
102 |
layout.getLayoutControl().getCurrentLayoutTool().mouseDragged(e); |
|
103 |
} catch (BehaviorException t) { |
|
104 |
throwException(t); |
|
105 |
} |
|
106 |
layout.getLayoutControl().setPosition(e.getPoint()); |
|
107 |
} |
|
108 |
|
|
109 |
/** |
|
110 |
* @see java.awt.event.MouseMotionListener#mouseMoved(java.awt.event.MouseEvent) |
|
111 |
*/ |
|
112 |
public void mouseMoved(MouseEvent e) { |
|
113 |
layout.getLayoutControl().setPosition(e.getPoint()); |
|
114 |
try { |
|
115 |
layout.getLayoutControl().getCurrentLayoutTool().mouseMoved(e); |
|
116 |
} catch (BehaviorException t) { |
|
117 |
throwException(t); |
|
118 |
} |
|
119 |
layout.repaint(); |
|
120 |
} |
|
121 |
|
|
122 |
/** |
|
123 |
* @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent) |
|
124 |
*/ |
|
125 |
public void mouseClicked(MouseEvent e) { |
|
126 |
try { |
|
127 |
layout.getLayoutControl().getComponent().requestFocusInWindow(); |
|
128 |
layout.getLayoutControl().getCurrentLayoutTool().mouseClicked(e); |
|
129 |
} catch (BehaviorException t) { |
|
130 |
throwException(t); |
|
131 |
} |
|
132 |
} |
|
133 |
|
|
134 |
/** |
|
135 |
* A?ade un listener de tipo ExceptionListener. |
|
136 |
* |
|
137 |
* @param o |
|
138 |
* ExceptionListener. |
|
139 |
*/ |
|
140 |
public void addExceptionListener(ExceptionListener o) { |
|
141 |
exceptionHandlingSupport.addExceptionListener(o); |
|
142 |
} |
|
143 |
|
|
144 |
/** |
|
145 |
* Borra la ExceptioListener que se pasa como par?metro. |
|
146 |
* |
|
147 |
* @param o |
|
148 |
* ExceptionListener. |
|
149 |
* |
|
150 |
* @return True si se borra correctamente. |
|
151 |
*/ |
|
152 |
public boolean removeExceptionListener(ExceptionListener o) { |
|
153 |
return exceptionHandlingSupport.removeExceptionListener(o); |
|
154 |
} |
|
155 |
|
|
156 |
/** |
|
157 |
* Lanza una Excepci?n. |
|
158 |
* |
|
159 |
* @param t |
|
160 |
* Excepci?n. |
|
161 |
*/ |
|
162 |
protected void throwException(Throwable t) { |
|
163 |
exceptionHandlingSupport.throwException(t); |
|
164 |
} |
|
165 |
|
|
166 |
/** |
|
167 |
* @see java.awt.event.MouseListener#mouseEntered(java.awt.event.MouseEvent) |
|
168 |
*/ |
|
169 |
public void mouseEntered(MouseEvent e) { |
|
170 |
layout.getLayoutControl().clearMouseImage(); |
|
171 |
try { |
|
172 |
layout.getLayoutControl().getCurrentLayoutTool().mouseEntered(e); |
|
173 |
} catch (BehaviorException t) { |
|
174 |
throwException(t); |
Also available in: Unified diff