Revision 228
trunk/org.gvsig.app.document.layout2.app/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/gui/preferencespage/LayoutPage.java | ||
---|---|---|
21 | 21 |
*/ |
22 | 22 |
package org.gvsig.app.gui.preferencespage; |
23 | 23 |
|
24 |
import java.awt.GridBagConstraints; |
|
24 | 25 |
import java.awt.Insets; |
25 | 26 |
|
26 | 27 |
import javax.swing.BorderFactory; |
27 | 28 |
import javax.swing.ImageIcon; |
28 | 29 |
import javax.swing.JCheckBox; |
30 |
import javax.swing.JComboBox; |
|
31 |
import javax.swing.JLabel; |
|
29 | 32 |
import javax.swing.JPanel; |
30 | 33 |
import javax.swing.JTextField; |
31 | 34 |
|
... | ... | |
37 | 40 |
import org.gvsig.app.project.ProjectManager; |
38 | 41 |
import org.gvsig.app.project.documents.layout.Attributes; |
39 | 42 |
import org.gvsig.app.project.documents.layout.DefaultLayoutManager; |
43 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
40 | 44 |
import org.gvsig.gui.beans.swing.GridBagLayoutPanel; |
41 | 45 |
import org.gvsig.i18n.Messages; |
42 | 46 |
import org.gvsig.utils.XMLEntity; |
... | ... | |
66 | 70 |
private JTextField txtHGap; |
67 | 71 |
private JCheckBox chkShowInitialPageConfig; |
68 | 72 |
private JCheckBox chkShowLayoutTOC; |
73 |
private JComboBox cbHGapUnit; |
|
74 |
private JComboBox cbVGapUnit; |
|
69 | 75 |
|
70 | 76 |
private static DefaultLayoutManager layoutManager = null; |
71 | 77 |
|
... | ... | |
93 | 99 |
Insets lastInsets = new Insets(8, 10, 12, 10); |
94 | 100 |
gridRulerPanel.setBorder(BorderFactory.createTitledBorder(Messages.getText("Grid_and_ruler"))); |
95 | 101 |
|
96 |
// horizontal gap text field |
|
97 |
gridRulerPanel.addComponent(PluginServices.getText(this, "espaciado_horizontal"), |
|
98 |
txtHGap = new JTextField(5), topInsets); |
|
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); |
|
99 | 118 |
|
100 |
// vertical gap text field |
|
101 |
gridRulerPanel.addComponent(PluginServices.getText(this, "espaciado_vertical"), |
|
102 |
txtVGap = new JTextField(5), insets); |
|
103 |
|
|
104 | 119 |
// show/hide show check |
105 | 120 |
gridRulerPanel.addComponent(chkShowGrid = |
106 | 121 |
new JCheckBox(PluginServices.getText(this, "visualizar_cuadricula")), insets); |
... | ... | |
134 | 149 |
double hGap, vGap; |
135 | 150 |
boolean gridEnabled, showRules, showGrid, showInitPageConfig, |
136 | 151 |
showLayoutToc; |
152 |
String hGapUnits, vGapUnits; |
|
137 | 153 |
try { |
138 | 154 |
hGap = Double.parseDouble(txtHGap.getText()); |
155 |
hGapUnits = MapContext.getDistanceAbbr()[cbHGapUnit.getSelectedIndex()]; |
|
139 | 156 |
vGap = Double.parseDouble(txtVGap.getText()); |
157 |
vGapUnits = MapContext.getDistanceAbbr()[cbVGapUnit.getSelectedIndex()]; |
|
140 | 158 |
gridEnabled = chkGridEnabled.isSelected(); |
141 | 159 |
showGrid = chkShowGrid.isSelected(); |
142 | 160 |
showRules = chkShowRules.isSelected(); |
... | ... | |
149 | 167 |
layoutManager.setDefaultShowGrid(showGrid); |
150 | 168 |
layoutManager.setDefaultAdjustToGrid(gridEnabled); |
151 | 169 |
layoutManager.setDefaultShowRulers(showRules); |
152 |
Attributes.setDefaultGridGap(hGap, vGap); |
|
170 |
Attributes.setDefaultGridGap(hGap, vGap, hGapUnits, vGapUnits);
|
|
153 | 171 |
PluginServices ps = PluginsLocator.getManager().getPlugin(this); |
154 | 172 |
XMLEntity xml = ps.getPersistentXML(); |
155 | 173 |
xml.putProperty(PreferenceKeys.DEFAULT_LAYOUT_GRID_HORIZONTAL_GAP_KEY_NAME, hGap); |
156 | 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); |
|
157 | 177 |
xml.putProperty(PreferenceKeys.DEFAULT_SHOW_LAYOUT_GRID_KEY_NAME, showGrid); |
158 | 178 |
xml.putProperty(PreferenceKeys.DEFAULT_ENABLE_LAYOUT_GRID_KEY_NAME, gridEnabled); |
159 | 179 |
xml.putProperty(PreferenceKeys.DEFAULT_SHOW_LAYOUT_RULERS_KEY_NAME, showRules); |
... | ... | |
196 | 216 |
xml.getDoubleProperty(PreferenceKeys.DEFAULT_LAYOUT_GRID_VERTICAL_GAP_KEY_NAME); |
197 | 217 |
} |
198 | 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)); |
|
199 | 229 |
|
200 | 230 |
// show/hide grid check |
201 | 231 |
if (xml.contains(PreferenceKeys.DEFAULT_SHOW_LAYOUT_GRID_KEY_NAME)) { |
... | ... | |
231 | 261 |
layoutManager.setDefaultShowGrid(showGrid); |
232 | 262 |
layoutManager.setDefaultAdjustToGrid(gridEnabled); |
233 | 263 |
layoutManager.setDefaultShowRulers(showRules); |
234 |
Attributes.setDefaultGridGap(hGap, vGap); |
|
264 |
Attributes.setDefaultGridGap(hGap, vGap, hGapUnit, vGapUnit);
|
|
235 | 265 |
} |
236 | 266 |
|
237 | 267 |
public void initializeDefaults() { |
238 | 268 |
txtHGap.setText(String.valueOf(PreferenceKeys.FACTORY_DEFAULT_HORIZONTAL_GAP)); |
239 | 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)); |
|
240 | 272 |
chkShowGrid.setSelected(PreferenceKeys.FACTORY_DEFAULT_LAYOUT_GRID_SHOW); |
241 | 273 |
chkGridEnabled.setSelected(PreferenceKeys.FACTORY_DEFAULT_LAYOUT_GRID_ENABLE); |
242 | 274 |
chkShowRules.setSelected(PreferenceKeys.FACTORY_DEFAULT_LAYOUT_ENABLE_RULERS); |
trunk/org.gvsig.app.document.layout2.app/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/gui/preferencespage/PreferenceKeys.java | ||
---|---|---|
15 | 15 |
String DEFAULT_SHOW_LAYOUT_RULERS_KEY_NAME = "DefaultShowLayoutRules"; |
16 | 16 |
String DEFAULT_LAYOUT_GRID_VERTICAL_GAP_KEY_NAME = "DefaultGridVerticalGap"; |
17 | 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"; |
|
18 | 20 |
String DEFAULT_SHOW_INITIAL_CONFIG_DIALOG_KEY_NAME = "DefaulShowInitialPageConfigLayout"; |
19 | 21 |
String DEFAULT_SHOW_LAYOUT_TOC_KEY_NAME = "DefaultShowLayoutToc"; |
20 | 22 |
boolean FACTORY_DEFAULT_LAYOUT_ENABLE_RULERS = true; |
21 | 23 |
boolean FACTORY_DEFAULT_LAYOUT_GRID_SHOW = true; |
22 | 24 |
double FACTORY_DEFAULT_VERTICAL_GAP = 1.0d; |
23 | 25 |
double FACTORY_DEFAULT_HORIZONTAL_GAP = 1.0d; |
26 |
String FACTORY_DEFAULT_VERTICAL_GAP_UNIT = "cm"; |
|
27 |
String FACTORY_DEFAULT_HORIZONTAL_GAP_UNIT = "cm"; |
|
24 | 28 |
boolean FACTORY_DEFAULT_LAYOUT_GRID_ENABLE = false; |
25 | 29 |
boolean FACTORY_DEFAULT_SHOW_INITIAL_CONFIG_DIALOG_FOR_LAYOUT = true; |
26 | 30 |
boolean FACTORY_DEFAULT_SHOW_LAYOUT_TOC = true; |
trunk/org.gvsig.app.document.layout2.app/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/gui/MapProperties.java | ||
---|---|---|
116 | 116 |
|
117 | 117 |
getTxtHorizontal().setText( |
118 | 118 |
Double.toString(map.getLayoutContext().getAttributes() |
119 |
.getNumUnitsX()));
|
|
119 |
.getHGridGapCm()));
|
|
120 | 120 |
getTxtVertical().setText( |
121 | 121 |
Double.toString(map.getLayoutContext().getAttributes() |
122 |
.getNumUnitsY()));
|
|
122 |
.getVGridGapCm()));
|
|
123 | 123 |
|
124 | 124 |
getChkActiveGrid().setSelected( |
125 | 125 |
map.getLayoutContext().isAdjustingToGrid()); |
... | ... | |
641 | 641 |
if (sh.length() != 0) { |
642 | 642 |
double f = new Double(sh).doubleValue(); |
643 | 643 |
map.getLayoutContext().getAttributes() |
644 |
.setNumUnitsX(f);
|
|
644 |
.setHGridGrapCm(f);
|
|
645 | 645 |
} |
646 | 646 |
|
647 | 647 |
String sv = txtVertical.getText(); |
... | ... | |
649 | 649 |
if (sv.length() != 0) { |
650 | 650 |
double f = new Double(sv).doubleValue(); |
651 | 651 |
map.getLayoutContext().getAttributes() |
652 |
.setNumUnitsY(f);
|
|
652 |
.setVGridGrapCm(f);
|
|
653 | 653 |
} |
654 | 654 |
|
655 | 655 |
PluginServices.getMDIManager().closeWindow( |
trunk/org.gvsig.app.document.layout2.app/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/gui/DefaultLayoutPanel.java | ||
---|---|---|
587 | 587 |
private void setLayoutContext(LayoutContext theLayoutcontext) { |
588 | 588 |
this.layoutContext = theLayoutcontext; |
589 | 589 |
this.layoutControl.setLayoutContext(theLayoutcontext); |
590 |
layoutContext.getAttributes().setDistanceUnitX(layoutControl.getRect());
|
|
591 |
layoutContext.getAttributes().setDistanceUnitY(layoutControl.getRect());
|
|
590 |
layoutContext.getAttributes().calculateGridGapX(layoutControl.getRect());
|
|
591 |
layoutContext.getAttributes().calculateGridGapY(layoutControl.getRect());
|
|
592 | 592 |
layoutControl.setDefaultTool(); |
593 | 593 |
} |
594 | 594 |
|
... | ... | |
607 | 607 |
layoutControl.setCancelDrawing(false); |
608 | 608 |
|
609 | 609 |
double scale = 0; |
610 |
scale = layoutControl.getRect().height / layoutContext.getAttributes().m_sizePaper.getAlto() * 1;
|
|
610 |
scale = layoutControl.getRect().height / layoutContext.getAttributes().m_sizePaper.getHeight() * 1;
|
|
611 | 611 |
AffineTransform escalado = new AffineTransform(); |
612 | 612 |
AffineTransform translacion = new AffineTransform(); |
613 | 613 |
translacion.setToTranslation(layoutControl.getRect().getMinX(), layoutControl.getRect().getMinY()); |
... | ... | |
615 | 615 |
layoutControl.getAT().setToIdentity(); |
616 | 616 |
layoutControl.getAT().concatenate(translacion); |
617 | 617 |
layoutControl.getAT().concatenate(escalado); |
618 |
layoutContext.getAttributes().setDistanceUnitX(layoutControl.getRect());
|
|
619 |
layoutContext.getAttributes().setDistanceUnitY(layoutControl.getRect());
|
|
618 |
layoutContext.getAttributes().calculateGridGapX(layoutControl.getRect());
|
|
619 |
layoutContext.getAttributes().calculateGridGapY(layoutControl.getRect());
|
|
620 | 620 |
IFFrame[] fframes=layoutContext.getFFrames(); |
621 | 621 |
|
622 | 622 |
for (int i = 0; i < fframes.length; i++) { |
trunk/org.gvsig.app.document.layout2.app/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/gui/dialogs/EventsFAlign.java | ||
---|---|---|
162 | 162 |
private void alignCenterVL() throws CloneNotSupportedException { |
163 | 163 |
double xcenter = 0; |
164 | 164 |
xcenter = |
165 |
m_layout.getLayoutContext().getAttributes().m_sizePaper.getAncho() / 2;
|
|
165 |
m_layout.getLayoutContext().getAttributes().m_sizePaper.getWidth() / 2;
|
|
166 | 166 |
|
167 | 167 |
IFFrame[] fframes = m_layout.getLayoutContext().getSelectedFFrames(); |
168 | 168 |
FrameCommandsRecord efs = |
... | ... | |
225 | 225 |
private void alignRightL() throws CloneNotSupportedException { |
226 | 226 |
double xmax = 0; |
227 | 227 |
xmax = |
228 |
m_layout.getLayoutContext().getAttributes().m_sizePaper.getAncho();
|
|
228 |
m_layout.getLayoutContext().getAttributes().m_sizePaper.getWidth();
|
|
229 | 229 |
|
230 | 230 |
IFFrame[] fframes = m_layout.getLayoutContext().getSelectedFFrames(); |
231 | 231 |
FrameCommandsRecord efs = |
... | ... | |
288 | 288 |
private void alignDownL() throws CloneNotSupportedException { |
289 | 289 |
double ymax = 0; |
290 | 290 |
ymax = |
291 |
m_layout.getLayoutContext().getAttributes().m_sizePaper.getAlto();
|
|
291 |
m_layout.getLayoutContext().getAttributes().m_sizePaper.getHeight();
|
|
292 | 292 |
|
293 | 293 |
IFFrame[] fframes = m_layout.getLayoutContext().getSelectedFFrames(); |
294 | 294 |
FrameCommandsRecord efs = |
... | ... | |
409 | 409 |
private void alignCenterHL() throws CloneNotSupportedException { |
410 | 410 |
double ycenter = 0; |
411 | 411 |
ycenter = |
412 |
m_layout.getLayoutContext().getAttributes().m_sizePaper.getAlto() / 2;
|
|
412 |
m_layout.getLayoutContext().getAttributes().m_sizePaper.getHeight() / 2;
|
|
413 | 413 |
|
414 | 414 |
IFFrame[] fframes = m_layout.getLayoutContext().getSelectedFFrames(); |
415 | 415 |
FrameCommandsRecord efs = |
... | ... | |
482 | 482 |
double xmin = 0; |
483 | 483 |
double xmax = 0; |
484 | 484 |
xmax = |
485 |
m_layout.getLayoutContext().getAttributes().m_sizePaper.getAncho();
|
|
485 |
m_layout.getLayoutContext().getAttributes().m_sizePaper.getWidth();
|
|
486 | 486 |
|
487 | 487 |
int num = 0; |
488 | 488 |
IFFrame[] fframes = m_layout.getLayoutContext().getSelectedFFrames(); |
... | ... | |
558 | 558 |
double xmin = 0; |
559 | 559 |
double xmax = 0; |
560 | 560 |
xmax = |
561 |
m_layout.getLayoutContext().getAttributes().m_sizePaper.getAncho();
|
|
561 |
m_layout.getLayoutContext().getAttributes().m_sizePaper.getWidth();
|
|
562 | 562 |
|
563 | 563 |
int num = 0; |
564 | 564 |
IFFrame[] fframes = m_layout.getLayoutContext().getSelectedFFrames(); |
... | ... | |
634 | 634 |
double ymin = 0; |
635 | 635 |
double ymax = 0; |
636 | 636 |
ymax = |
637 |
m_layout.getLayoutContext().getAttributes().m_sizePaper.getAlto();
|
|
637 |
m_layout.getLayoutContext().getAttributes().m_sizePaper.getHeight();
|
|
638 | 638 |
|
639 | 639 |
int num = 0; |
640 | 640 |
IFFrame[] fframes = m_layout.getLayoutContext().getSelectedFFrames(); |
... | ... | |
713 | 713 |
double ymin = 0; |
714 | 714 |
double ymax = 0; |
715 | 715 |
ymax = |
716 |
m_layout.getLayoutContext().getAttributes().m_sizePaper.getAlto();
|
|
716 |
m_layout.getLayoutContext().getAttributes().m_sizePaper.getHeight();
|
|
717 | 717 |
|
718 | 718 |
int num = 0; |
719 | 719 |
IFFrame[] fframes = m_layout.getLayoutContext().getSelectedFFrames(); |
... | ... | |
793 | 793 |
double xmin = 0; |
794 | 794 |
double xmax = 0; |
795 | 795 |
xmax = |
796 |
m_layout.getLayoutContext().getAttributes().m_sizePaper.getAncho();
|
|
796 |
m_layout.getLayoutContext().getAttributes().m_sizePaper.getWidth();
|
|
797 | 797 |
|
798 | 798 |
int num = 0; |
799 | 799 |
IFFrame[] fframes = m_layout.getLayoutContext().getSelectedFFrames(); |
... | ... | |
874 | 874 |
double ymin = 0; |
875 | 875 |
double ymax = 0; |
876 | 876 |
ymax = |
877 |
m_layout.getLayoutContext().getAttributes().m_sizePaper.getAlto();
|
|
877 |
m_layout.getLayoutContext().getAttributes().m_sizePaper.getHeight();
|
|
878 | 878 |
|
879 | 879 |
int num = 0; |
880 | 880 |
IFFrame[] fframes = m_layout.getLayoutContext().getSelectedFFrames(); |
... | ... | |
1013 | 1013 |
if (inLayout) { |
1014 | 1014 |
total += |
1015 | 1015 |
(xmin + (m_layout.getLayoutContext().getAttributes().m_sizePaper |
1016 |
.getAncho() - xmax));
|
|
1016 |
.getWidth() - xmax));
|
|
1017 | 1017 |
num += 2; |
1018 | 1018 |
} |
1019 | 1019 |
|
... | ... | |
1095 | 1095 |
if (inLayout) { |
1096 | 1096 |
total += |
1097 | 1097 |
(ymin + (m_layout.getLayoutContext().getAttributes().m_sizePaper |
1098 |
.getAlto() - ymax));
|
|
1098 |
.getHeight() - ymax));
|
|
1099 | 1099 |
num += 2; |
1100 | 1100 |
} |
1101 | 1101 |
|
trunk/org.gvsig.app.document.layout2.app/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/gui/dialogs/FConfigLayoutDialog.java | ||
---|---|---|
276 | 276 |
m_layout.getLayoutContext().getAttributes() |
277 | 277 |
.getSizeinUnits(isLand, type); |
278 | 278 |
getTAlto().setText( |
279 |
String.valueOf(nf.format(size.getAlto())));
|
|
279 |
String.valueOf(nf.format(size.getHeight())));
|
|
280 | 280 |
getTAncho().setText( |
281 |
String.valueOf(nf.format(size.getAncho())));
|
|
281 |
String.valueOf(nf.format(size.getWidth())));
|
|
282 | 282 |
setMargin(margin); |
283 | 283 |
if (cbTipoFolio.getSelectedItem().equals( |
284 | 284 |
PluginServices.getText(this, "Personalizado"))) { |
... | ... | |
325 | 325 |
m_layout.getLayoutContext().getAttributes() |
326 | 326 |
.getSizeinUnits(isLand, type); |
327 | 327 |
getTAlto().setText( |
328 |
String.valueOf(nf.format(size.getAncho())));
|
|
328 |
String.valueOf(nf.format(size.getWidth())));
|
|
329 | 329 |
getTAncho().setText( |
330 |
String.valueOf(nf.format(size.getAlto())));
|
|
330 |
String.valueOf(nf.format(size.getHeight())));
|
|
331 | 331 |
setMargin(margin); |
332 | 332 |
} |
333 | 333 |
}); |
... | ... | |
373 | 373 |
Size size = |
374 | 374 |
m_layout.getLayoutContext().getAttributes() |
375 | 375 |
.getSizeinUnits(isLand, type); |
376 |
String s = String.valueOf(nf.format(size.getAncho()));
|
|
376 |
String s = String.valueOf(nf.format(size.getWidth()));
|
|
377 | 377 |
tAncho.setText(s); |
378 | 378 |
if (getCbTipoFolio().getSelectedItem().equals( |
379 | 379 |
PluginServices.getText(this, "Personalizado"))) { |
... | ... | |
397 | 397 |
Size size = |
398 | 398 |
m_layout.getLayoutContext().getAttributes() |
399 | 399 |
.getSizeinUnits(isLand, type); |
400 |
String s = String.valueOf(nf.format(size.getAlto()));
|
|
400 |
String s = String.valueOf(nf.format(size.getHeight()));
|
|
401 | 401 |
tAlto.setText(s); |
402 | 402 |
if (getCbTipoFolio().getSelectedItem().equals( |
403 | 403 |
PluginServices.getText(this, "Personalizado"))) { |
... | ... | |
721 | 721 |
ffv.setDocument(m_layout.getDocument()); |
722 | 722 |
LayoutContext lctxt = m_layout.getLayoutContext(); |
723 | 723 |
ffv.setLayoutContext(lctxt); |
724 |
ffv.setBoundBox(new Rectangle2D.Double(izq, sup, attributes.getPaperSize().getAncho()-(izq+der), attributes.getPaperSize().getAlto()-(sup+inf)));
|
|
724 |
ffv.setBoundBox(new Rectangle2D.Double(izq, sup, attributes.getPaperSize().getWidth()-(izq+der), attributes.getPaperSize().getHeight()-(sup+inf)));
|
|
725 | 725 |
ffv.setView(vd); |
726 | 726 |
lctxt.addFFrame(ffv, true, true); |
727 | 727 |
m_layout.getLayoutControl().setDefaultTool(); |
... | ... | |
831 | 831 |
m_layout.getLayoutContext().getAttributes() |
832 | 832 |
.getSizeinUnits(isLand, type); |
833 | 833 |
getTAncho().setText( |
834 |
String.valueOf(nf.format(size.getAncho())));
|
|
834 |
String.valueOf(nf.format(size.getWidth())));
|
|
835 | 835 |
getTAlto().setText( |
836 |
String.valueOf(nf.format(size.getAlto())));
|
|
836 |
String.valueOf(nf.format(size.getHeight())));
|
|
837 | 837 |
} |
838 | 838 |
}); |
839 | 839 |
} |
... | ... | |
872 | 872 |
m_layout.getLayoutContext().getAttributes() |
873 | 873 |
.getSizeinUnits(isLand, type); |
874 | 874 |
getTAncho().setText( |
875 |
String.valueOf(nf.format(size.getAncho())));
|
|
875 |
String.valueOf(nf.format(size.getWidth())));
|
|
876 | 876 |
getTAlto().setText( |
877 |
String.valueOf(nf.format(size.getAlto())));
|
|
877 |
String.valueOf(nf.format(size.getHeight())));
|
|
878 | 878 |
} |
879 | 879 |
}); |
880 | 880 |
} |
trunk/org.gvsig.app.document.layout2.app/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/gui/dialogs/FPositionDialog.java | ||
---|---|---|
420 | 420 |
if (layout.getLayoutContext().getAttributes().isLandscape()) { |
421 | 421 |
lAnchoUnidades.setText(String.valueOf(nf.format(layout |
422 | 422 |
.getLayoutContext().getAttributes().getSizeInUnits() |
423 |
.getAlto())));
|
|
423 |
.getHeight())));
|
|
424 | 424 |
} else { |
425 | 425 |
lAnchoUnidades.setText(String.valueOf(nf.format(layout |
426 | 426 |
.getLayoutContext().getAttributes().getSizeInUnits() |
427 |
.getAncho())));
|
|
427 |
.getWidth())));
|
|
428 | 428 |
} |
429 | 429 |
} |
430 | 430 |
|
... | ... | |
457 | 457 |
if (layout.getLayoutContext().getAttributes().isLandscape()) { |
458 | 458 |
lAltoUnidades.setText(String.valueOf(nf.format(layout |
459 | 459 |
.getLayoutContext().getAttributes().getSizeInUnits() |
460 |
.getAncho())));
|
|
460 |
.getWidth())));
|
|
461 | 461 |
} else { |
462 | 462 |
lAltoUnidades.setText(String.valueOf(nf.format(layout |
463 | 463 |
.getLayoutContext().getAttributes().getSizeInUnits() |
464 |
.getAlto())));
|
|
464 |
.getHeight())));
|
|
465 | 465 |
} |
466 | 466 |
} |
467 | 467 |
|
trunk/org.gvsig.app.document.layout2.app/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/Size.java | ||
---|---|---|
60 | 60 |
} |
61 | 61 |
|
62 | 62 |
/** |
63 |
* Devuelve el alto del folio.
|
|
63 |
* Gets the height of the sheet, measured in centimeters.
|
|
64 | 64 |
* |
65 |
* @return altura.
|
|
65 |
* @return Height.
|
|
66 | 66 |
*/ |
67 |
public double getAlto() {
|
|
67 |
public double getHeight() {
|
|
68 | 68 |
return alto; |
69 | 69 |
} |
70 | 70 |
|
71 | 71 |
/** |
72 |
* Devuelve la anchura del folio.
|
|
72 |
* Gets the width of the sheet, measured in centimeters.
|
|
73 | 73 |
* |
74 |
* @return Anchura.
|
|
74 |
* @return Width of the sheet.
|
|
75 | 75 |
*/ |
76 |
public double getAncho() {
|
|
76 |
public double getWidth() {
|
|
77 | 77 |
return ancho; |
78 | 78 |
} |
79 | 79 |
|
trunk/org.gvsig.app.document.layout2.app/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/FLayoutUtilities.java | ||
---|---|---|
296 | 296 |
|
297 | 297 |
return true; |
298 | 298 |
} |
299 |
|
|
300 |
/** |
|
301 |
* Devuelve un long representando a la escala en funci?n de que unidad de |
|
302 |
* medida se pase como par?metro. |
|
303 |
* |
|
304 |
* @param map |
|
305 |
* FMap |
|
306 |
* @param h |
|
307 |
* Rect?ngulo. |
|
308 |
* |
|
309 |
* @return escala. |
|
310 |
*/ |
|
311 |
public static long getScaleView( |
|
312 |
ViewPort viewPort, |
|
313 |
double wcm, |
|
314 |
double wpixels) { |
|
315 |
|
|
316 |
double dpi = (2.54*wpixels) / wcm; |
|
317 |
IProjection proj = viewPort.getProjection(); |
|
318 |
|
|
319 |
if (viewPort.getAdjustedEnvelope() == null) { |
|
320 |
return 0; |
|
321 |
} |
|
322 |
|
|
323 |
int mUnits = viewPort.getMapUnits(); |
|
324 |
double[] trans2Meter = MapContext.getDistanceTrans2Meter(); |
|
325 |
if (proj == null || viewPort.getImageSize() == null) { |
|
326 |
return (long) (viewPort.getAdjustedEnvelope().getLength(1) |
|
327 |
/ 100.0d*wcm * trans2Meter[mUnits]); |
|
328 |
} |
|
329 |
|
|
330 |
return (long) proj.getScale( |
|
331 |
viewPort.getAdjustedEnvelope().getMinimum(0) * trans2Meter[mUnits], |
|
332 |
viewPort.getAdjustedEnvelope().getMaximum(0) * trans2Meter[mUnits], |
|
333 |
wpixels, dpi); |
|
334 |
} |
|
335 | 299 |
|
336 |
|
|
337 |
|
|
338 | 300 |
public static List<Document> removeEditing(List<Document> list) { |
339 | 301 |
|
340 | 302 |
List<Document> resp = new ArrayList<Document>(); |
trunk/org.gvsig.app.document.layout2.app/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/tools/LayoutEditGraphicsListenerImpl.java | ||
---|---|---|
67 | 67 |
((IFFrameEditableVertex) frame).pointDragged(FLayoutUtilities |
68 | 68 |
.toSheetPoint(event.getPoint(), layoutPanel |
69 | 69 |
.getLayoutControl().getAT())); |
70 |
// layout.setStatus(Layout.GRAPHICS); |
|
71 |
|
|
72 | 70 |
} |
73 | 71 |
} |
74 | 72 |
} |
trunk/org.gvsig.app.document.layout2.app/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/DefaultLayoutControl.java | ||
---|---|---|
485 | 485 |
&& getCurrentLayoutTool().isAdjustable()) { |
486 | 486 |
position = |
487 | 487 |
FLayoutUtilities.getPointGrid(point2, layoutContext |
488 |
.getAttributes().getNumUnitsX(), layoutContext
|
|
489 |
.getAttributes().getNumUnitsY(), layoutContext.getAT());
|
|
488 |
.getAttributes().getHGridGapCm(), layoutContext
|
|
489 |
.getAttributes().getVGridGapCm(), layoutContext.getAT());
|
|
490 | 490 |
} else { |
491 | 491 |
position = point2; |
492 | 492 |
} |
trunk/org.gvsig.app.document.layout2.app/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/Attributes.java | ||
---|---|---|
21 | 21 |
*/ |
22 | 22 |
package org.gvsig.app.project.documents.layout; |
23 | 23 |
|
24 |
import java.awt.Rectangle; |
|
25 | 24 |
import java.awt.geom.Point2D; |
26 | 25 |
import java.awt.geom.Rectangle2D; |
27 | 26 |
import java.awt.print.PageFormat; |
28 | 27 |
import java.awt.print.Paper; |
29 | 28 |
import java.text.NumberFormat; |
29 |
import java.util.ArrayList; |
|
30 | 30 |
|
31 |
import javax.crypto.Mac; |
|
32 | 31 |
import javax.print.attribute.HashPrintRequestAttributeSet; |
33 | 32 |
import javax.print.attribute.PrintRequestAttributeSet; |
34 | 33 |
import javax.print.attribute.standard.Copies; |
... | ... | |
41 | 40 |
import javax.print.attribute.standard.Sides; |
42 | 41 |
|
43 | 42 |
import org.gvsig.andami.PluginServices; |
43 |
import org.gvsig.andami.PluginsLocator; |
|
44 | 44 |
import org.gvsig.app.extension.LayoutExtension; |
45 |
import org.gvsig.app.gui.preferencespage.PreferenceKeys; |
|
45 | 46 |
import org.gvsig.compat.CompatLocator; |
46 | 47 |
import org.gvsig.compat.print.PrintAttributes; |
47 | 48 |
import org.gvsig.fmap.mapcontext.MapContext; |
49 |
import org.gvsig.i18n.Messages; |
|
48 | 50 |
import org.gvsig.tools.ToolsLocator; |
49 | 51 |
import org.gvsig.tools.dynobject.DynStruct; |
50 | 52 |
import org.gvsig.tools.persistence.PersistenceManager; |
... | ... | |
77 | 79 |
public static final String SELTYPEUNIT_FIELD = "selTypeUnit"; |
78 | 80 |
public static final String SIZEPAPER_FIELD = "sizePaper"; |
79 | 81 |
public static final String AREA_FIELD = "area"; |
80 |
// public static final String WIDTHXHEIGHT_FIELD = "widthXHeight"; |
|
81 | 82 |
public static final String SIZEINUNITS_FIELD = "sizeInUnits"; |
82 | 83 |
public static final String ISLANDSEL_FIELD = "isLandSel"; |
83 | 84 |
public static final String DEGREES = "Grados"; |
... | ... | |
88 | 89 |
// Para impresi?n |
89 | 90 |
public final static double PULGADA = 2.54; |
90 | 91 |
|
91 |
// public final static Size CUSTOM_PAPER_SIZE = new Size(8.5, 11.0); |
|
92 | 92 |
public final static Size STANDARD_LETTER_PAPER_SIZE = new Size(8.5, 11.0); |
93 | 93 |
public final static Size STANDARD_FOLIO_PAPER_SIZE = new Size(8.5, 13.0); |
94 | 94 |
public final static Size STANDARD_LEGAL_PAPER_SIZE = new Size(8.5, 14.0); |
... | ... | |
134 | 134 |
/** |
135 | 135 |
* Change factor from configured map unit (m_selTypeUnit) to centimeters |
136 | 136 |
*/ |
137 |
private double m_TypeUnit = 100.0d*MapContext.getDistanceTrans2Meter()[2]; // [2] = Centimeters
|
|
137 |
private double m_TypeUnit = getConversionFactorToCm(2); // [2] = Centimeters
|
|
138 | 138 |
private String m_NameUnit; |
139 | 139 |
/** |
140 |
* Horizontal space between grid lines, measured in the configured map unit (m_selTypeUnit)
|
|
140 |
* Horizontal space between grid lines, measured in centimeters
|
|
141 | 141 |
*/ |
142 |
private Double m_numX = null;
|
|
142 |
private Double m_gridGapCmX = null;
|
|
143 | 143 |
/** |
144 |
* Vertical space between grid lines, measured in the configured map unit (m_selTypeUnit)
|
|
144 |
* Vertical space between grid lines, measured in centimeters
|
|
145 | 145 |
*/ |
146 |
private Double m_numY = null; |
|
147 |
private double m_unitX = 0; |
|
148 |
private double m_unitY = 0; |
|
146 |
private Double m_gridGapCmY = null; |
|
147 |
/** |
|
148 |
* Horizontal space between grid lines, measured in centimeters |
|
149 |
*/ |
|
150 |
private double m_gridGapPxX = 0; |
|
151 |
/** |
|
152 |
* Vertical space between grid lines, measured in pixels |
|
153 |
*/ |
|
154 |
private double m_gridGapPxY = 0; |
|
149 | 155 |
private boolean hasmargin; |
150 | 156 |
private int m_resolutionSel = NORMAL; |
151 | 157 |
private int m_typeSel = PRINT; |
... | ... | |
162 | 168 |
* (it does not "know" about portrait/landscape) |
163 | 169 |
*/ |
164 | 170 |
public Size m_sizePaper = new Size( |
165 |
METRIC_A4_PAPER_SIZE.getAlto(),
|
|
166 |
METRIC_A4_PAPER_SIZE.getAncho());
|
|
171 |
METRIC_A4_PAPER_SIZE.getHeight(),
|
|
172 |
METRIC_A4_PAPER_SIZE.getWidth());
|
|
167 | 173 |
|
168 | 174 |
/** |
169 | 175 |
* Print area (top, bottom, left, right). |
... | ... | |
188 | 194 |
* |
189 | 195 |
*/ |
190 | 196 |
public Attributes() { |
191 |
m_NameUnit = PluginServices.getText(this, "Centimetros");
|
|
197 |
m_NameUnit = Messages.getText("Centimetros");
|
|
192 | 198 |
m_Orientation = OrientationRequested.LANDSCAPE; |
193 | 199 |
m_type = MediaSizeName.ISO_A4; |
194 | 200 |
resetSizeinUnits(isLandscape()); |
... | ... | |
204 | 210 |
|
205 | 211 |
if (isLandscape()) { |
206 | 212 |
attributes.add(new MediaPrintableArea(0, 0, |
207 |
(float) ((m_sizePaper.getAlto() * DPISCREEN) / PULGADA),
|
|
208 |
(float) ((m_sizePaper.getAncho() * DPISCREEN) / PULGADA),
|
|
213 |
(float) ((m_sizePaper.getHeight() * DPISCREEN) / PULGADA),
|
|
214 |
(float) ((m_sizePaper.getWidth() * DPISCREEN) / PULGADA),
|
|
209 | 215 |
MediaPrintableArea.MM)); |
210 | 216 |
} else { |
211 | 217 |
attributes.add(new MediaPrintableArea(0, 0, |
212 |
(float) ((m_sizePaper.getAncho() * DPISCREEN) / PULGADA),
|
|
213 |
(float) ((m_sizePaper.getAlto() * DPISCREEN) / PULGADA),
|
|
218 |
(float) ((m_sizePaper.getWidth() * DPISCREEN) / PULGADA),
|
|
219 |
(float) ((m_sizePaper.getHeight() * DPISCREEN) / PULGADA),
|
|
214 | 220 |
MediaPrintableArea.MM)); |
215 | 221 |
} |
216 | 222 |
} |
... | ... | |
279 | 285 |
Paper paper = pf1.getPaper(); |
280 | 286 |
|
281 | 287 |
paper.setSize( |
282 |
(m_sizePaper.getAncho() * DPISCREEN) / PULGADA,
|
|
283 |
(m_sizePaper.getAlto() * DPISCREEN) / PULGADA);
|
|
288 |
(m_sizePaper.getWidth() * DPISCREEN) / PULGADA,
|
|
289 |
(m_sizePaper.getHeight() * DPISCREEN) / PULGADA);
|
|
284 | 290 |
|
285 | 291 |
if (isLandscape()) { |
286 | 292 |
pf1.setOrientation(0); |
... | ... | |
295 | 301 |
paper.setImageableArea( |
296 | 302 |
getInPixels(area_tblr[1]), |
297 | 303 |
getInPixels(area_tblr[2]), |
298 |
getInPixels(m_sizeinUnits.getAlto() - area_tblr[0] - area_tblr[1]),
|
|
299 |
getInPixels(m_sizeinUnits.getAncho() - area_tblr[2] - area_tblr[3]));
|
|
304 |
getInPixels(m_sizeinUnits.getHeight() - area_tblr[0] - area_tblr[1]),
|
|
305 |
getInPixels(m_sizeinUnits.getWidth() - area_tblr[2] - area_tblr[3]));
|
|
300 | 306 |
} else { |
301 | 307 |
// portrait |
302 | 308 |
pf1.setOrientation(1); |
303 | 309 |
paper.setImageableArea( |
304 | 310 |
getInPixels(area_tblr[2]), |
305 | 311 |
getInPixels(area_tblr[0]), |
306 |
getInPixels(m_sizeinUnits.getAncho() - area_tblr[2] - area_tblr[3]),
|
|
307 |
getInPixels(m_sizeinUnits.getAlto() - area_tblr[0] - area_tblr[1]));
|
|
312 |
getInPixels(m_sizeinUnits.getWidth() - area_tblr[2] - area_tblr[3]),
|
|
313 |
getInPixels(m_sizeinUnits.getHeight() - area_tblr[0] - area_tblr[1]));
|
|
308 | 314 |
} |
309 | 315 |
|
310 | 316 |
pf1.setPaper(paper); |
... | ... | |
348 | 354 |
rect.setRect( |
349 | 355 |
area_tblr[2], |
350 | 356 |
area_tblr[0], |
351 |
m_sizePaper.getAlto() - area_tblr[2] - area_tblr[3],
|
|
352 |
m_sizePaper.getAncho() - area_tblr[0] - area_tblr[1]);
|
|
357 |
m_sizePaper.getHeight() - area_tblr[2] - area_tblr[3],
|
|
358 |
m_sizePaper.getWidth() - area_tblr[0] - area_tblr[1]);
|
|
353 | 359 |
} else { |
354 | 360 |
rect.setRect( |
355 | 361 |
area_tblr[2], |
356 | 362 |
area_tblr[0], |
357 |
m_sizePaper.getAncho() - area_tblr[2] - area_tblr[3],
|
|
358 |
m_sizePaper.getAlto() - area_tblr[0] - area_tblr[1]);
|
|
363 |
m_sizePaper.getWidth() - area_tblr[2] - area_tblr[3],
|
|
364 |
m_sizePaper.getHeight() - area_tblr[0] - area_tblr[1]);
|
|
359 | 365 |
} |
360 | 366 |
return rect; |
361 | 367 |
} |
... | ... | |
395 | 401 |
area_tblr[1] = getInCM(pf.getImageableX()); |
396 | 402 |
area_tblr[2] = getInCM(pf.getImageableY()); |
397 | 403 |
area_tblr[0] = |
398 |
portrait_size.getAncho() - getInCM(pf.getImageableHeight())
|
|
404 |
portrait_size.getWidth() - getInCM(pf.getImageableHeight())
|
|
399 | 405 |
- area_tblr[1]; |
400 | 406 |
area_tblr[3] = |
401 |
portrait_size.getAlto() - getInCM(pf.getImageableWidth())
|
|
407 |
portrait_size.getHeight() - getInCM(pf.getImageableWidth())
|
|
402 | 408 |
- area_tblr[2]; |
403 | 409 |
} else { |
404 | 410 |
// portrait |
405 | 411 |
area_tblr[2] = getInCM(pf.getImageableX()); |
406 | 412 |
area_tblr[0] = getInCM(pf.getImageableY()); |
407 | 413 |
area_tblr[1] = |
408 |
portrait_size.getAlto() - getInCM(pf.getImageableHeight())
|
|
414 |
portrait_size.getHeight() - getInCM(pf.getImageableHeight())
|
|
409 | 415 |
- area_tblr[0]; |
410 | 416 |
area_tblr[3] = |
411 |
portrait_size.getAncho() - getInCM(pf.getImageableWidth())
|
|
417 |
portrait_size.getWidth() - getInCM(pf.getImageableWidth())
|
|
412 | 418 |
- area_tblr[2]; |
413 | 419 |
} |
414 | 420 |
|
... | ... | |
451 | 457 |
MediaPrintableArea.MM)); |
452 | 458 |
|
453 | 459 |
resul.add(m_resolution); |
454 |
// resul.add(new PrinterResolution(DPI,DPI,PrinterResolution.DPI)); |
|
455 | 460 |
return resul; |
456 | 461 |
} |
457 | 462 |
|
... | ... | |
492 | 497 |
|
493 | 498 |
resul.add(m_type); |
494 | 499 |
|
495 |
// units, no hace falta a?adirlo a attributes |
|
496 | 500 |
resul.add(m_Orientation); |
497 |
// setArea(area_tblr); |
|
498 | 501 |
|
499 | 502 |
Rectangle2D rect = this.getArea(); |
500 | 503 |
resul.add(new MediaPrintableArea( |
... | ... | |
504 | 507 |
(float) (rect.getHeight() * DPISCREEN / PULGADA), |
505 | 508 |
MediaPrintableArea.MM)); |
506 | 509 |
|
507 |
/* |
|
508 |
resul.add(new MediaPrintableArea(0, 0, |
|
509 |
(float) ((m_sizePaper.getAncho() * DPISCREEN) / PULGADA), |
|
510 |
(float) ((m_sizePaper.getAlto() * DPISCREEN) / PULGADA), |
|
511 |
MediaPrintableArea.MM)); |
|
512 |
*/ |
|
513 |
|
|
514 | 510 |
resul.add(m_resolution); |
515 |
// resul.add(new PrinterResolution(DPI,DPI,PrinterResolution.DPI)); |
|
516 | 511 |
return resul; |
517 | 512 |
} |
518 |
|
|
519 | 513 |
/** |
520 |
* Inserts printing area. |
|
521 |
* |
|
522 |
* @param area |
|
523 |
* Printing area. |
|
524 |
*/ |
|
525 |
|
|
526 |
/* |
|
527 |
private void setArea(double[] a_tblr) { |
|
528 |
if (!isLandSpace()) { |
|
529 |
// portrait |
|
530 |
attributes.add(new MediaPrintableArea( |
|
531 |
(float) (a_tblr[2] * 10), |
|
532 |
(float) (a_tblr[0] * 10), |
|
533 |
(float) ((m_sizePaper.getAncho() - a_tblr[2] - a_tblr[3]) * 10), |
|
534 |
(float) ((m_sizePaper.getAlto() - a_tblr[0] - a_tblr[1]) * 10), |
|
535 |
MediaPrintableArea.MM)); |
|
536 |
|
|
537 |
} else { |
|
538 |
// landscape |
|
539 |
attributes.add(new MediaPrintableArea( |
|
540 |
(float) (a_tblr[0] * 10), |
|
541 |
(float) (a_tblr[3] * 10), |
|
542 |
(float) ((m_sizePaper.getAlto() - a_tblr[0] - a_tblr[1]) * 10), |
|
543 |
(float) ((m_sizePaper.getAncho() - a_tblr[3] - a_tblr[2]) * 10), |
|
544 |
MediaPrintableArea.MM)); |
|
545 |
|
|
546 |
} |
|
547 |
} |
|
548 |
*/ |
|
549 |
|
|
550 |
/** |
|
551 | 514 |
* Returns true if the margin should be used. |
552 | 515 |
* |
553 | 516 |
* @return True if margin should be used. |
... | ... | |
635 | 598 |
* @param d |
636 | 599 |
* number of units to define the grid. |
637 | 600 |
*/ |
638 |
public void setNumUnitsX(double d) {
|
|
639 |
m_numX = new Double(d);
|
|
601 |
public void setHGridGrapCm(double d) {
|
|
602 |
m_gridGapCmX = new Double(d);
|
|
640 | 603 |
} |
641 | 604 |
|
642 | 605 |
/** |
643 |
* Returns the number of pixels that represents a unit of coords X. |
|
606 |
* Gets the grid gap for the x axis, in centimeters. The grip gap is the |
|
607 |
* distance from one point to the next point in the snapping grid. |
|
644 | 608 |
* |
645 |
* @return Number of pixels coords X.
|
|
609 |
* @return Default grid gap for the x axis, measured in centimeters
|
|
646 | 610 |
*/ |
647 |
|
|
648 |
public double getNumUnitsX() { |
|
649 |
if (m_numX == null) { |
|
650 |
m_numX = new Double(getDefaultGridGap().getX()); |
|
611 |
public double getHGridGapCm() { |
|
612 |
if (m_gridGapCmX == null) { |
|
613 |
m_gridGapCmX = new Double(getDefaultGridGap().getX()); |
|
651 | 614 |
} |
652 |
return m_numX.doubleValue();
|
|
615 |
return m_gridGapCmX.doubleValue();
|
|
653 | 616 |
} |
654 | 617 |
|
655 | 618 |
/** |
656 |
* Returns the number of pixels that represents a unit of coords Y. |
|
619 |
* Gets the grid gap for the y axis, in centimeters. The grip gap is the |
|
620 |
* distance from one point to the next point in the snapping grid. |
|
657 | 621 |
* |
658 |
* @return Number of pixels coords Y.
|
|
622 |
* @return Default grid gap for the y axis, measured in centimeters
|
|
659 | 623 |
*/ |
660 |
|
|
661 |
public double getNumUnitsY() { |
|
662 |
if (m_numY == null) { |
|
663 |
m_numY = new Double(getDefaultGridGap().getY()); |
|
624 |
public double getVGridGapCm() { |
|
625 |
if (m_gridGapCmY == null) { |
|
626 |
m_gridGapCmY = new Double(getDefaultGridGap().getY()); |
|
664 | 627 |
} |
665 |
return m_numY.doubleValue();
|
|
628 |
return m_gridGapCmY.doubleValue();
|
|
666 | 629 |
} |
667 | 630 |
|
668 | 631 |
/** |
... | ... | |
671 | 634 |
* @param d |
672 | 635 |
* number of units to define the grid. |
673 | 636 |
*/ |
674 |
public void setNumUnitsY(double d) {
|
|
675 |
m_numY = new Double(d);
|
|
637 |
public void setVGridGrapCm(double d) {
|
|
638 |
m_gridGapCmY = new Double(d);
|
|
676 | 639 |
} |
677 | 640 |
|
678 | 641 |
/** |
... | ... | |
706 | 669 |
|
707 | 670 |
if (isLandscape()) { |
708 | 671 |
m_sizePaper = |
709 |
new Size(METRIC_A4_PAPER_SIZE.getAncho(),
|
|
710 |
METRIC_A4_PAPER_SIZE.getAlto());
|
|
672 |
new Size(METRIC_A4_PAPER_SIZE.getWidth(),
|
|
673 |
METRIC_A4_PAPER_SIZE.getHeight());
|
|
711 | 674 |
} else { |
712 | 675 |
m_sizePaper = METRIC_A4_PAPER_SIZE; |
713 | 676 |
} |
... | ... | |
719 | 682 |
|
720 | 683 |
if (isLandscape()) { |
721 | 684 |
m_sizePaper = |
722 |
new Size(METRIC_A4_PAPER_SIZE.getAncho(),
|
|
723 |
METRIC_A4_PAPER_SIZE.getAlto());
|
|
685 |
new Size(METRIC_A4_PAPER_SIZE.getWidth(),
|
|
686 |
METRIC_A4_PAPER_SIZE.getHeight());
|
|
724 | 687 |
} else { |
725 | 688 |
m_sizePaper = METRIC_A4_PAPER_SIZE; |
726 | 689 |
} |
... | ... | |
732 | 695 |
|
733 | 696 |
if (isLandscape()) { |
734 | 697 |
m_sizePaper = |
735 |
new Size(METRIC_A3_PAPER_SIZE.getAncho(),
|
|
736 |
METRIC_A3_PAPER_SIZE.getAlto());
|
|
698 |
new Size(METRIC_A3_PAPER_SIZE.getWidth(),
|
|
699 |
METRIC_A3_PAPER_SIZE.getHeight());
|
|
737 | 700 |
} else { |
738 | 701 |
m_sizePaper = METRIC_A3_PAPER_SIZE; |
739 | 702 |
} |
... | ... | |
745 | 708 |
|
746 | 709 |
if (isLandscape()) { |
747 | 710 |
m_sizePaper = |
748 |
new Size(METRIC_A2_PAPER_SIZE.getAncho(),
|
|
749 |
METRIC_A2_PAPER_SIZE.getAlto());
|
|
711 |
new Size(METRIC_A2_PAPER_SIZE.getWidth(),
|
|
712 |
METRIC_A2_PAPER_SIZE.getHeight());
|
|
750 | 713 |
} else { |
751 | 714 |
m_sizePaper = METRIC_A2_PAPER_SIZE; |
752 | 715 |
} |
... | ... | |
758 | 721 |
|
759 | 722 |
if (isLandscape()) { |
760 | 723 |
m_sizePaper = |
761 |
new Size(METRIC_A1_PAPER_SIZE.getAncho(),
|
|
762 |
METRIC_A1_PAPER_SIZE.getAlto());
|
|
724 |
new Size(METRIC_A1_PAPER_SIZE.getWidth(),
|
|
725 |
METRIC_A1_PAPER_SIZE.getHeight());
|
|
763 | 726 |
} else { |
764 | 727 |
m_sizePaper = METRIC_A1_PAPER_SIZE; |
765 | 728 |
} |
... | ... | |
771 | 734 |
|
772 | 735 |
if (isLandscape()) { |
773 | 736 |
m_sizePaper = |
774 |
new Size(METRIC_A0_PAPER_SIZE.getAncho(),
|
|
775 |
METRIC_A0_PAPER_SIZE.getAlto());
|
|
737 |
new Size(METRIC_A0_PAPER_SIZE.getWidth(),
|
|
738 |
METRIC_A0_PAPER_SIZE.getHeight());
|
|
776 | 739 |
} else { |
777 | 740 |
m_sizePaper = METRIC_A0_PAPER_SIZE; |
778 | 741 |
} |
... | ... | |
782 | 745 |
case (CUSTOM): |
783 | 746 |
m_type = MediaSizeName.PERSONAL_ENVELOPE; |
784 | 747 |
m_sizePaper = new Size( |
785 |
CUSTOM_PAPER_SIZE.getAlto()*m_TypeUnit,
|
|
786 |
CUSTOM_PAPER_SIZE.getAncho()*m_TypeUnit);
|
|
748 |
CUSTOM_PAPER_SIZE.getHeight()*m_TypeUnit,
|
|
749 |
CUSTOM_PAPER_SIZE.getWidth()*m_TypeUnit);
|
|
787 | 750 |
break; |
788 | 751 |
} |
789 | 752 |
attributes.add(m_type); |
... | ... | |
808 | 771 |
|
809 | 772 |
if (isLand) { |
810 | 773 |
size = |
811 |
new Size(METRIC_A4_PAPER_SIZE.getAncho(),
|
|
812 |
METRIC_A4_PAPER_SIZE.getAlto());
|
|
774 |
new Size(METRIC_A4_PAPER_SIZE.getWidth(),
|
|
775 |
METRIC_A4_PAPER_SIZE.getHeight());
|
|
813 | 776 |
} else { |
814 | 777 |
size = METRIC_A4_PAPER_SIZE; |
815 | 778 |
} |
... | ... | |
820 | 783 |
|
821 | 784 |
if (isLand) { |
822 | 785 |
size = |
823 |
new Size(METRIC_A4_PAPER_SIZE.getAncho(),
|
|
824 |
METRIC_A4_PAPER_SIZE.getAlto());
|
|
786 |
new Size(METRIC_A4_PAPER_SIZE.getWidth(),
|
|
787 |
METRIC_A4_PAPER_SIZE.getHeight());
|
|
825 | 788 |
} else { |
826 | 789 |
size = METRIC_A4_PAPER_SIZE; |
827 | 790 |
} |
... | ... | |
832 | 795 |
|
833 | 796 |
if (isLand) { |
834 | 797 |
size = |
835 |
new Size(METRIC_A3_PAPER_SIZE.getAncho(),
|
|
836 |
METRIC_A3_PAPER_SIZE.getAlto());
|
|
798 |
new Size(METRIC_A3_PAPER_SIZE.getWidth(),
|
|
799 |
METRIC_A3_PAPER_SIZE.getHeight());
|
|
837 | 800 |
} else { |
838 | 801 |
size = METRIC_A3_PAPER_SIZE; |
839 | 802 |
} |
... | ... | |
844 | 807 |
|
845 | 808 |
if (isLand) { |
846 | 809 |
size = |
847 |
new Size(METRIC_A2_PAPER_SIZE.getAncho(),
|
|
848 |
METRIC_A2_PAPER_SIZE.getAlto());
|
|
810 |
new Size(METRIC_A2_PAPER_SIZE.getWidth(),
|
|
811 |
METRIC_A2_PAPER_SIZE.getHeight());
|
|
849 | 812 |
} else { |
850 | 813 |
size = METRIC_A2_PAPER_SIZE; |
851 | 814 |
} |
... | ... | |
856 | 819 |
|
857 | 820 |
if (isLand) { |
858 | 821 |
size = |
859 |
new Size(METRIC_A1_PAPER_SIZE.getAncho(),
|
|
860 |
METRIC_A1_PAPER_SIZE.getAlto());
|
|
822 |
new Size(METRIC_A1_PAPER_SIZE.getWidth(),
|
|
823 |
METRIC_A1_PAPER_SIZE.getHeight());
|
|
861 | 824 |
} else { |
862 | 825 |
size = METRIC_A1_PAPER_SIZE; |
863 | 826 |
} |
... | ... | |
868 | 831 |
|
869 | 832 |
if (isLand) { |
870 | 833 |
size = |
871 |
new Size(METRIC_A0_PAPER_SIZE.getAncho(),
|
|
872 |
METRIC_A0_PAPER_SIZE.getAlto());
|
|
834 |
new Size(METRIC_A0_PAPER_SIZE.getWidth(),
|
|
835 |
METRIC_A0_PAPER_SIZE.getHeight());
|
|
873 | 836 |
} else { |
874 | 837 |
size = METRIC_A0_PAPER_SIZE; |
875 | 838 |
} |
... | ... | |
880 | 843 |
if (isLandscape()) { |
881 | 844 |
size = |
882 | 845 |
new Size( |
883 |
CUSTOM_PAPER_SIZE.getAncho() * m_TypeUnit,
|
|
884 |
CUSTOM_PAPER_SIZE.getAlto() * m_TypeUnit);
|
|
846 |
CUSTOM_PAPER_SIZE.getWidth() * m_TypeUnit,
|
|
847 |
CUSTOM_PAPER_SIZE.getHeight() * m_TypeUnit);
|
|
885 | 848 |
} else { |
886 | 849 |
size = |
887 | 850 |
new Size( |
888 |
CUSTOM_PAPER_SIZE.getAlto() * m_TypeUnit,
|
|
889 |
CUSTOM_PAPER_SIZE.getAncho() * m_TypeUnit);
|
|
851 |
CUSTOM_PAPER_SIZE.getHeight() * m_TypeUnit,
|
|
852 |
CUSTOM_PAPER_SIZE.getWidth() * m_TypeUnit);
|
|
890 | 853 |
} |
891 | 854 |
break; |
892 | 855 |
} |
893 | 856 |
|
894 | 857 |
Size resp = new Size( |
895 |
size.getAlto() / m_TypeUnit,
|
|
896 |
size.getAncho() / m_TypeUnit);
|
|
858 |
size.getHeight() / m_TypeUnit,
|
|
859 |
size.getWidth() / m_TypeUnit);
|
|
897 | 860 |
|
898 | 861 |
return resp; |
899 | 862 |
} |
... | ... | |
929 | 892 |
|
930 | 893 |
case (CUSTOM): |
931 | 894 |
size = new Size( |
932 |
CUSTOM_PAPER_SIZE.getAlto(),
|
|
933 |
CUSTOM_PAPER_SIZE.getAncho());
|
|
895 |
CUSTOM_PAPER_SIZE.getHeight(),
|
|
896 |
CUSTOM_PAPER_SIZE.getWidth());
|
|
934 | 897 |
break; |
935 | 898 |
} |
936 | 899 |
|
... | ... | |
941 | 904 |
|
942 | 905 |
|
943 | 906 |
/** |
944 |
* Returns the type of units is in use (cm, mm, km, etc), codified as
|
|
907 |
* Returns the type of unit in use (cm, mm, km, etc), codified as |
|
945 | 908 |
* a position in the array returned by {@link MapContext#getDistanceNames()} |
946 | 909 |
* |
947 | 910 |
* @see #setUnit(int) |
... | ... | |
969 | 932 |
} |
970 | 933 |
|
971 | 934 |
/** |
972 |
* Selecting the type of unit that is utilized in the Layout, by default is |
|
973 |
* in centimetres. |
|
935 |
* Sets the type of unit that is used in the Layout, defined as an |
|
936 |
* integer indicating a position in the array |
|
937 |
* {@link MapContext#getDistanceNames()}. By default is |
|
938 |
* centimeters. |
|
974 | 939 |
* |
975 | 940 |
* @param sel |
976 | 941 |
* Type of unit. |
... | ... | |
981 | 946 |
.getLogger(LayoutExtension.class); |
982 | 947 |
logger.debug("setUnit: "+sel); |
983 | 948 |
m_selTypeUnit = sel; |
984 |
m_TypeUnit = 100.0d*MapContext.getDistanceTrans2Meter()[sel];
|
|
949 |
m_TypeUnit = getConversionFactorToCm(sel);
|
|
985 | 950 |
m_NameUnit = |
986 | 951 |
PluginServices.getText(this, MapContext.getDistanceNames()[sel]); |
987 |
m_numX = m_numY = new Double(0.25/m_TypeUnit); // 0.25 cm / unit_to_cm |
|
988 | 952 |
} |
989 | 953 |
|
990 | 954 |
/** |
... | ... | |
997 | 961 |
public void resetSizeinUnits(boolean is_landscape) { |
998 | 962 |
if (is_landscape) { |
999 | 963 |
m_sizeinUnits = |
1000 |
new Size(m_sizePaper.getAlto() / m_TypeUnit,
|
|
1001 |
m_sizePaper.getAncho() / m_TypeUnit);
|
|
964 |
new Size(m_sizePaper.getHeight() / m_TypeUnit,
|
|
965 |
m_sizePaper.getWidth() / m_TypeUnit);
|
|
1002 | 966 |
} else { |
1003 | 967 |
m_sizeinUnits = |
1004 |
new Size(m_sizePaper.getAncho() / m_TypeUnit,
|
|
1005 |
m_sizePaper.getAlto() / m_TypeUnit);
|
|
968 |
new Size(m_sizePaper.getWidth() / m_TypeUnit,
|
|
969 |
m_sizePaper.getHeight() / m_TypeUnit);
|
|
1006 | 970 |
} |
1007 | 971 |
} |
1008 | 972 |
|
... | ... | |
1046 | 1010 |
* @return Pixels from centimeter. |
1047 | 1011 |
*/ |
1048 | 1012 |
public double getPixXCm(Rectangle2D rect) { |
1049 |
double value = m_sizePaper.getAncho();
|
|
1050 |
double cm = 100.0d*MapContext.getDistanceTrans2Meter()[2];
|
|
1013 |
double value = m_sizePaper.getWidth();
|
|
1014 |
double cm = getConversionFactorToCm(2);
|
|
1051 | 1015 |
double unidades = 0; |
1052 | 1016 |
unidades = ((rect.getMaxX() - rect.getMinX()) / ((value / cm))); |
1053 | 1017 |
return unidades; |
1054 | 1018 |
} |
1055 | 1019 |
|
1056 | 1020 |
/** |
1057 |
* Inserts the number of pixels of one centimeter of X. |
|
1021 |
* Calculates the grid gap for the x axis, in pixels, |
|
1022 |
* based on the paper width (in cm) and the width |
|
1023 |
* of the rectangle of sheet in screen, measured in |
|
1024 |
* pixels. |
|
1025 |
* |
|
1026 |
* The grip gap is the distance from one |
|
1027 |
* point to the next point in the snapping grid. |
|
1058 | 1028 |
* |
1059 | 1029 |
* @param rect |
1060 |
* Rectangle of sheet.
|
|
1030 |
* Rectangle of sheet, measured in pixels
|
|
1061 | 1031 |
*/ |
1062 |
public void setDistanceUnitX(Rectangle2D rect) { |
|
1063 |
double value = m_sizePaper.getAncho(); |
|
1032 |
public void calculateGridGapX(Rectangle2D rect) { |
|
1033 |
double width = m_sizePaper.getWidth(); |
|
1034 |
double numberOfGaps = width / getHGridGapCm(); |
|
1064 | 1035 |
double unidades = |
1065 |
((rect.getMaxX() - rect.getMinX()) / ((value / m_TypeUnit) / getNumUnitsX()));
|
|
1066 |
m_unitX = unidades;
|
|
1036 |
(rect.getMaxX() - rect.getMinX()) / numberOfGaps;
|
|
1037 |
m_gridGapPxX = unidades;
|
|
1067 | 1038 |
} |
1068 | 1039 |
|
1069 | 1040 |
/** |
1070 |
* Inserts the number of pixels of one centimeter of Y. |
|
1041 |
* Calculates the grid gap for the y axis, in pixels, |
|
1042 |
* based on the paper height (in cm) and the height |
|
1043 |
* of the rectangle of sheet in screen, measured in |
|
1044 |
* pixels. |
|
1045 |
* |
|
1046 |
* The grip gap is the distance from one |
|
1047 |
* point to the next point in the snapping grid. |
|
1071 | 1048 |
* |
1072 | 1049 |
* @param rect |
1073 |
* Rectangle of sheet.
|
|
1050 |
* Rectangle of sheet, measured in pixels
|
|
1074 | 1051 |
*/ |
1075 |
public void setDistanceUnitY(Rectangle2D rect) { |
|
1076 |
double value = m_sizePaper.getAncho(); |
|
1052 |
public void calculateGridGapY(Rectangle2D rect) { |
|
1053 |
double height = m_sizePaper.getHeight(); |
|
1054 |
double numberOfGaps = height / getVGridGapCm(); |
|
1077 | 1055 |
double unidades = |
1078 |
((rect.getMaxX() - rect.getMinX()) / ((value / m_TypeUnit) / getNumUnitsY()));
|
|
1079 |
m_unitY = unidades;
|
|
1056 |
(rect.getMaxY() - rect.getMinY()) / numberOfGaps;
|
|
1057 |
m_gridGapPxY = unidades;
|
|
1080 | 1058 |
} |
1081 | 1059 |
|
1082 | 1060 |
|
1083 | 1061 |
private double getPaperSizeRatio() { |
1084 | 1062 |
double resp = 1; |
1085 | 1063 |
if (isLandscape()) { |
1086 |
resp = m_sizePaper.getAncho() / m_sizePaper.getAlto();
|
|
1064 |
resp = m_sizePaper.getWidth() / m_sizePaper.getHeight();
|
|
1087 | 1065 |
} else { |
1088 |
resp = m_sizePaper.getAlto() / m_sizePaper.getAncho();
|
|
1066 |
resp = m_sizePaper.getHeight() / m_sizePaper.getWidth();
|
|
1089 | 1067 |
} |
1090 | 1068 |
return resp; |
1091 | 1069 |
} |
... | ... | |
1108 | 1086 |
rect = getRectanglePortrait(rect, w, h); |
1109 | 1087 |
} |
1110 | 1088 |
} else { |
1111 |
value1 = m_sizePaper.getAncho();
|
|
1112 |
value2 = m_sizePaper.getAlto();
|
|
1089 |
value1 = m_sizePaper.getWidth();
|
|
1090 |
value2 = m_sizePaper.getHeight();
|
|
1113 | 1091 |
rect.setRect(0, 0, ((value1 / PULGADA) * DPI), |
1114 | 1092 |
((value2 / PULGADA) * DPI)); |
1115 | 1093 |
} |
1116 | 1094 |
|
1117 |
setDistanceUnitX(rect);
|
|
1118 |
setDistanceUnitY(rect);
|
|
1095 |
calculateGridGapX(rect);
|
|
1096 |
calculateGridGapY(rect);
|
|
1119 | 1097 |
} |
1120 | 1098 |
|
1121 | 1099 |
/** |
... | ... | |
1207 | 1185 |
Size portrait_size = null; |
1208 | 1186 |
|
1209 | 1187 |
if (is_portrait) { |
1210 |
portrait_size = new Size(size.getAlto(), size.getAncho());
|
|
1188 |
portrait_size = new Size(size.getHeight(), size.getWidth());
|
|
1211 | 1189 |
} else { |
1212 |
portrait_size = new Size(size.getAncho(), size.getAlto());
|
|
1190 |
portrait_size = new Size(size.getWidth(), size.getHeight());
|
|
1213 | 1191 |
} |
1214 | 1192 |
|
1215 |
if ((((portrait_size.getAncho() * PULGADA) / DPISCREEN) < (tol + METRIC_A4_PAPER_SIZE
|
|
1216 |
.getAncho()))
|
|
1217 |
&& (((portrait_size.getAlto() * PULGADA) / DPISCREEN) < (tol + METRIC_A4_PAPER_SIZE
|
|
1218 |
.getAlto()))) {
|
|
1193 |
if ((((portrait_size.getWidth() * PULGADA) / DPISCREEN) < (tol + METRIC_A4_PAPER_SIZE
|
|
1194 |
.getWidth()))
|
|
1195 |
&& (((portrait_size.getHeight() * PULGADA) / DPISCREEN) < (tol + METRIC_A4_PAPER_SIZE
|
|
1196 |
.getHeight()))) {
|
|
1219 | 1197 |
return A4; |
1220 | 1198 |
} else |
1221 |
if ((((portrait_size.getAncho() * PULGADA) / DPISCREEN) < (tol + METRIC_A3_PAPER_SIZE
|
|
1222 |
.getAncho()))
|
|
1223 |
&& (((portrait_size.getAlto() * PULGADA) / DPISCREEN) < (tol + METRIC_A3_PAPER_SIZE
|
|
1224 |
.getAlto()))) {
|
|
1199 |
if ((((portrait_size.getWidth() * PULGADA) / DPISCREEN) < (tol + METRIC_A3_PAPER_SIZE
|
|
1200 |
.getWidth()))
|
|
1201 |
&& (((portrait_size.getHeight() * PULGADA) / DPISCREEN) < (tol + METRIC_A3_PAPER_SIZE
|
|
1202 |
.getHeight()))) {
|
|
1225 | 1203 |
return A3; |
1226 | 1204 |
} else |
1227 |
if ((((portrait_size.getAncho() * PULGADA) / DPISCREEN) < (tol + METRIC_A2_PAPER_SIZE
|
|
1228 |
.getAncho()))
|
|
1229 |
&& (((portrait_size.getAlto() * PULGADA) / DPISCREEN) < (tol + METRIC_A2_PAPER_SIZE
|
|
1230 |
.getAlto()))) {
|
|
1205 |
if ((((portrait_size.getWidth() * PULGADA) / DPISCREEN) < (tol + METRIC_A2_PAPER_SIZE
|
|
1206 |
.getWidth()))
|
|
1207 |
&& (((portrait_size.getHeight() * PULGADA) / DPISCREEN) < (tol + METRIC_A2_PAPER_SIZE
|
|
1208 |
.getHeight()))) {
|
|
1231 | 1209 |
return A2; |
1232 | 1210 |
} else |
1233 |
if ((((portrait_size.getAncho() * PULGADA) / DPISCREEN) < (tol + METRIC_A1_PAPER_SIZE
|
|
1234 |
.getAncho()))
|
|
1235 |
&& (((portrait_size.getAlto() * PULGADA) / DPISCREEN) < (tol + METRIC_A1_PAPER_SIZE
|
|
1236 |
.getAlto()))) {
|
|
1211 |
if ((((portrait_size.getWidth() * PULGADA) / DPISCREEN) < (tol + METRIC_A1_PAPER_SIZE
|
|
1212 |
.getWidth()))
|
|
1213 |
&& (((portrait_size.getHeight() * PULGADA) / DPISCREEN) < (tol + METRIC_A1_PAPER_SIZE
|
|
1214 |
.getHeight()))) {
|
|
1237 | 1215 |
return A1; |
1238 | 1216 |
} else |
1239 |
if ((((portrait_size.getAncho() * PULGADA) / DPISCREEN) < (tol + METRIC_A0_PAPER_SIZE
|
|
1240 |
.getAncho()))
|
|
1241 |
&& (((portrait_size.getAlto() * PULGADA) / DPISCREEN) < (tol + METRIC_A0_PAPER_SIZE
|
|
1242 |
.getAlto()))) {
|
|
1217 |
if ((((portrait_size.getWidth() * PULGADA) / DPISCREEN) < (tol + METRIC_A0_PAPER_SIZE
|
|
1218 |
.getWidth()))
|
|
1219 |
&& (((portrait_size.getHeight() * PULGADA) / DPISCREEN) < (tol + METRIC_A0_PAPER_SIZE
|
|
1220 |
.getHeight()))) {
|
|
1243 | 1221 |
return A0; |
1244 | 1222 |
} |
1245 | 1223 |
|
... | ... | |
1247 | 1225 |
} |
1248 | 1226 |
|
1249 | 1227 |
/** |
1250 |
* Inserts the default number of pixels that represents a unit of grid. |
|
1228 |
* Sets the default grid gap. The grip gap is the distance from one |
|
1229 |
* point to the next point in the snapping grid. |
|
1251 | 1230 |
* |
1252 | 1231 |
* @param hGap |
1253 | 1232 |
* Horizontal distance. |
1254 | 1233 |
* @param vGap |
1255 | 1234 |
* Vertical distance. |
1235 |
* @param hUnitAbbr The abbreviation of the measure in which hGap has |
|
1236 |
* been provided, codified as one of the abbreviations specified in |
|
1237 |
* {@link MapContext#getDistanceAbbr()} |
|
1238 |
* |
|
1239 |
* @param vUnitAbbr The abbreviation of the measure in which vGap has |
|
1240 |
* been provided, codified as one of the abbreviations specified in |
|
1241 |
* {@link MapContext#getDistanceAbbr()} |
|
1256 | 1242 |
*/ |
1257 |
public static void setDefaultGridGap(double hGap, double vGap) { |
|
1258 |
defaultGridGap = new Point2D.Double(hGap, vGap); |
|
1243 |
public static void setDefaultGridGap(double hGap, double vGap, String hUnitAbbr, String vUnitAbbr) { |
|
1244 |
int hUnit = getDistanceAbbrPosition(hUnitAbbr); |
|
1245 |
int vUnit = getDistanceAbbrPosition(vUnitAbbr); |
|
1246 |
double hGapCm = hGap*getConversionFactorToCm(hUnit); |
|
1247 |
double vGapCm = vGap*getConversionFactorToCm(vUnit); |
|
1248 |
defaultGridGap = new Point2D.Double(hGapCm, vGapCm); |
|
1259 | 1249 |
} |
1260 | 1250 |
|
1261 | 1251 |
/** |
1262 |
* Returns the default number of pixels that represents a unit of grid. |
|
1252 |
* Gets the default grid gap, in centimeters. The grip gap is the distance |
|
1253 |
* from one point to the next point in the snapping grid. |
|
1263 | 1254 |
* |
1264 |
* @return Number of pixels of grid.
|
|
1255 |
* @return Default grid gap, measured in centimeters
|
|
1265 | 1256 |
*/ |
1266 | 1257 |
public static Point2D getDefaultGridGap() { |
1267 | 1258 |
if (defaultGridGap == null) { |
1268 |
PluginServices pluginServices = |
|
1269 |
PluginServices.getPluginServices("org.gvsig.app"); |
|
1259 |
PluginServices pluginServices = PluginsLocator.getManager().getPlugin(LayoutExtension.class); |
|
1270 | 1260 |
XMLEntity xml = null; |
1271 | 1261 |
if (pluginServices != null) { |
1272 | 1262 |
xml = pluginServices.getPersistentXML(); |
1273 | 1263 |
} |
1274 | 1264 |
double hGap = |
1275 | 1265 |
((xml != null) && (xml |
1276 |
.contains("DefaultLayoutGridHorizontalGapX"))) ? xml
|
|
1277 |
.getDoubleProperty("DefaultLayoutGridHorizontalGapX")
|
|
1278 |
: 0.25;
|
|
1266 |
.contains(PreferenceKeys.DEFAULT_LAYOUT_GRID_HORIZONTAL_GAP_KEY_NAME))) ? xml
|
|
1267 |
.getDoubleProperty(PreferenceKeys.DEFAULT_LAYOUT_GRID_HORIZONTAL_GAP_KEY_NAME)
|
|
1268 |
: PreferenceKeys.FACTORY_DEFAULT_HORIZONTAL_GAP;
|
|
1279 | 1269 |
double vGap = |
1280 | 1270 |
((xml != null) && (xml |
1281 |
.contains("DefaultLayoutGridHorizontalGapY"))) ? xml |
|
1282 |
.getDoubleProperty("DefaultLayoutGridHorizontalGapY") |
|
1283 |
: 0.25; |
|
1284 |
defaultGridGap = new Point2D.Double(hGap, vGap); |
|
1271 |
.contains(PreferenceKeys.DEFAULT_LAYOUT_GRID_VERTICAL_GAP_KEY_NAME))) ? xml |
|
1272 |
.getDoubleProperty(PreferenceKeys.DEFAULT_LAYOUT_GRID_VERTICAL_GAP_KEY_NAME) |
|
1273 |
: PreferenceKeys.FACTORY_DEFAULT_VERTICAL_GAP; |
|
1274 |
String hUnitName = ((xml != null) && (xml |
|
1275 |
.contains(PreferenceKeys.DEFAULT_LAYOUT_GRID_HORIZONTAL_GAP_UNITS_KEY_NAME))) ? xml |
|
1276 |
.getStringProperty(PreferenceKeys.DEFAULT_LAYOUT_GRID_HORIZONTAL_GAP_UNITS_KEY_NAME) |
|
1277 |
: PreferenceKeys.FACTORY_DEFAULT_VERTICAL_GAP_UNIT; // cm by default |
|
1278 |
String vUnitName = ((xml != null) && (xml |
|
1279 |
.contains(PreferenceKeys.DEFAULT_LAYOUT_GRID_VERTICAL_GAP_UNITS_KEY_NAME))) ? xml |
|
1280 |
.getStringProperty(PreferenceKeys.DEFAULT_LAYOUT_GRID_VERTICAL_GAP_UNITS_KEY_NAME) |
|
1281 |
: PreferenceKeys.FACTORY_DEFAULT_VERTICAL_GAP_UNIT; // cm by default |
|
1282 |
int hUnit = getDistanceAbbrPosition(hUnitName); |
|
1283 |
int vUnit = getDistanceAbbrPosition(vUnitName); |
|
1284 |
double hGapCm = hGap*getConversionFactorToCm(hUnit); |
|
1285 |
double vGapCm = vGap*getConversionFactorToCm(vUnit); |
|
1286 |
defaultGridGap = new Point2D.Double(hGapCm, vGapCm); |
|
1285 | 1287 |
} |
1286 | 1288 |
return defaultGridGap; |
1287 | 1289 |
} |
1290 |
|
|
1291 |
public static int getDistanceAbbrPosition(String unitAbbr) { |
|
1292 |
ArrayList list = MapContext.DISTANCEABBR; |
|
1293 |
for (int i = 0; i < list.size(); i++) { |
|
1294 |
if (list.get(i).equals(unitAbbr)){ |
|
1295 |
return i; |
|
1296 |
} |
|
1297 |
} |
|
1298 |
return 0; |
|
1299 |
|
|
1300 |
} |
|
1288 | 1301 |
|
1289 | 1302 |
/** |
1290 |
* Devuelve el n?mero de pixels de longitud en el eje Y que representa a la
|
|
1291 |
* unidad del mapa que est?
|
|
1292 |
* seleccionada, suelen ser cent?metros.
|
|
1303 |
* Gets the grid gap for the y axis, in pixels.
|
|
1304 |
* The grip gap is the distance from one
|
|
1305 |
* point to the next point in the snapping grid.
|
|
1293 | 1306 |
* |
1294 |
* @return n?mero de pixels que representa la unidad seleccionada.
|
|
1307 |
* @return Number of pixels of each grid gap for the y axis
|
|
1295 | 1308 |
*/ |
1296 |
public double getUnitInPixelsY() {
|
|
1297 |
return m_unitY;
|
|
1309 |
public double getVGridGapPx() {
|
|
1310 |
return m_gridGapPxY;
|
|
1298 | 1311 |
} |
1299 | 1312 |
|
1300 | 1313 |
/** |
1301 |
* Devuelve el n?mero de pixels de longitud en el eje X que representa a la
|
|
1302 |
* unidad del mapa que est?
|
|
1303 |
* seleccionada, suelen ser cent?metros.
|
|
1314 |
* Gets the grid gap for the x axis, in pixels.
|
|
1315 |
* The grip gap is the distance from one
|
|
1316 |
* point to the next point in the snapping grid.
|
|
1304 | 1317 |
* |
1305 |
* @return n?mero de pixels que representa la unidad seleccionada.
|
|
1318 |
* @return Number of pixels of each grid gap for the x axis
|
|
1306 | 1319 |
*/ |
1307 |
public double getUnitInPixelsX() {
|
|
1308 |
return m_unitX;
|
|
1320 |
public double getHGridGapPx() {
|
|
1321 |
return m_gridGapPxX;
|
|
1309 | 1322 |
} |
1310 | 1323 |
|
1311 | 1324 |
public static void registerPersistent() { |
... | ... | |
1344 | 1357 |
DPI = state.getInt(DPI_FIELD); |
1345 | 1358 |
DPISCREEN = state.getInt(DPISCREEN_FIELD); |
1346 | 1359 |
m_TypeUnit = state.getDouble(TYPEUNIT_FIELD); |
1347 |
m_numX = (Double) state.get(NUMX_FIELD);
|
|
1348 |
m_numY = (Double) state.get(NUMY_FIELD);
|
|
1349 |
m_unitX = (Double) state.get(UNITX_FIELD);
|
|
1350 |
m_unitY = (Double) state.get(UNITY_FIELD);
|
|
1360 |
m_gridGapCmX = (Double) state.get(NUMX_FIELD);
|
|
1361 |
m_gridGapCmY = (Double) state.get(NUMY_FIELD);
|
|
1362 |
m_gridGapPxX = (Double) state.get(UNITX_FIELD);
|
|
1363 |
m_gridGapPxY = (Double) state.get(UNITY_FIELD);
|
|
1351 | 1364 |
hasmargin = state.getBoolean(HASMARGIN_FIELD); |
1352 | 1365 |
m_resolutionSel = state.getInt(RESOLUTIONSEL_FIELD); |
1353 | 1366 |
m_typeSel = state.getInt(TYPESEL_FIELD); |
... | ... | |
1363 | 1376 |
state.set(DPI_FIELD, DPI); |
1364 | 1377 |
state.set(DPISCREEN_FIELD, DPISCREEN); |
1365 | 1378 |
state.set(TYPEUNIT_FIELD, m_TypeUnit); |
1366 |
state.set(NUMX_FIELD, m_numX);
|
|
1367 |
state.set(NUMY_FIELD, m_numY);
|
|
1368 |
state.set(UNITX_FIELD, m_unitX);
|
|
1369 |
state.set(UNITY_FIELD, m_unitY);
|
|
1379 |
state.set(NUMX_FIELD, m_gridGapCmX);
|
|
1380 |
state.set(NUMY_FIELD, m_gridGapCmY);
|
|
1381 |
state.set(UNITX_FIELD, m_gridGapPxX);
|
|
1382 |
state.set(UNITY_FIELD, m_gridGapPxY);
|
|
1370 | 1383 |
state.set(HASMARGIN_FIELD, hasmargin); |
1371 | 1384 |
state.set(RESOLUTIONSEL_FIELD, m_resolutionSel); |
1372 | 1385 |
state.set(TYPESEL_FIELD, m_typeSel); |
... | ... | |
1376 | 1389 |
state.set(SIZEINUNITS_FIELD, m_sizeinUnits); |
1377 | 1390 |
state.set(ISLANDSEL_FIELD, this.isLandscape()); |
1378 | 1391 |
} |
1392 |
|
|
1393 |
/** |
|
1394 |
* Gets the conversion factor from the specified unit to centimeters. |
|
1395 |
* If you have some distance measured in the specified unit, you can |
|
1396 |
* multiply it by this factor in order to convert the distance to cm. |
|
1397 |
* |
|
1398 |
* @param unit The source unit, codified as a position in the array |
|
1399 |
* {@link MapContext#getDistanceNames()} |
|
1400 |
* @return A conversion factor from the specified unit to cm |
|
1401 |
*/ |
|
1402 |
public static double getConversionFactorToCm(int unit) { |
|
1403 |
return 100.0d*MapContext.getDistanceTrans2Meter()[unit]; |
|
1404 |
} |
|
1379 | 1405 |
|
1380 | 1406 |
} |
trunk/org.gvsig.app.document.layout2.app/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/FLayoutDraw.java | ||
---|---|---|
150 | 150 |
layoutControl.setCancelDrawing(false); |
151 | 151 |
|
152 | 152 |
double scale = 0; |
153 |
scale = rLayout.getHeight() / attributes.m_sizePaper.getAlto() * 1; // paper (paper units) to screen (pixels) scale
|
|
153 |
scale = rLayout.getHeight() / attributes.m_sizePaper.getHeight() * 1; // paper (paper units) to screen (pixels) scale
|
|
154 | 154 |
AffineTransform escalado = new AffineTransform(); |
155 | 155 |
AffineTransform translacion = new AffineTransform(); |
156 | 156 |
translacion.setToTranslation(rLayout.getMinX(), rLayout.getMinY()); |
... | ... | |
158 | 158 |
at.setToIdentity(); |
159 | 159 |
at.concatenate(translacion); |
160 | 160 |
at.concatenate(escalado); |
161 |
attributes.setDistanceUnitX(rLayout);
|
|
162 |
attributes.setDistanceUnitY(rLayout);
|
|
161 |
attributes.calculateGridGapX(rLayout);
|
|
162 |
attributes.calculateGridGapY(rLayout);
|
|
163 | 163 |
return true; |
164 | 164 |
} |
165 | 165 |
|
... | ... | |
175 | 175 |
Rectangle2D rLayout = layoutControl.getRect(); |
176 | 176 |
AffineTransform at = layoutContext.getAT(); |
177 | 177 |
|
178 |
double unidadesX = attributes.getNumUnitsX();
|
|
179 |
double unidadesY = attributes.getNumUnitsY();
|
|
178 |
double unidadesX = attributes.getHGridGapCm();
|
|
179 |
double unidadesY = attributes.getVGridGapCm();
|
|
180 | 180 |
|
181 | 181 |
if ((unidadesX == 0) && (unidadesY == 0)) { |
182 | 182 |
return; |
... | ... | |
235 | 235 |
Rectangle2D rLayout = layoutControl.getRect(); |
236 | 236 |
AffineTransform at = layoutContext.getAT(); |
237 | 237 |
|
238 |
double unidadesX = attributes.getUnitInPixelsX();
|
|
239 |
double unidadesY = attributes.getUnitInPixelsY();
|
|
238 |
double unidadesX = attributes.getHGridGapPx();
|
|
239 |
double unidadesY = attributes.getVGridGapPx();
|
|
240 | 240 |
|
241 | 241 |
Rectangle2D.Double r = new Rectangle2D.Double(); |
242 | 242 |
|
... | ... | |
619 | 619 |
Document document = new Document(); |
620 | 620 |
|
621 | 621 |
if (attributes.isLandscape()) { |
622 |
w = ((attributes.m_sizePaper.getAlto() * Attributes.DPISCREEN) / Attributes.PULGADA);
|
|
623 |
h = ((attributes.m_sizePaper.getAncho() * Attributes.DPISCREEN) / Attributes.PULGADA);
|
|
622 |
w = ((attributes.m_sizePaper.getHeight() * Attributes.DPISCREEN) / Attributes.PULGADA);
|
|
623 |
h = ((attributes.m_sizePaper.getWidth() * Attributes.DPISCREEN) / Attributes.PULGADA);
|
|
624 | 624 |
} else { |
625 |
w = ((attributes.m_sizePaper.getAncho() * Attributes.DPISCREEN) / Attributes.PULGADA); |
|
626 |
h = ((attributes.m_sizePaper.getAlto() * Attributes.DPISCREEN) / Attributes.PULGADA); |
Also available in: Unified diff