Revision 11465
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/view/gui/ViewProperties.java | ||
---|---|---|
56 | 56 |
import com.iver.andami.PluginServices; |
57 | 57 |
import com.iver.andami.ui.mdiManager.SingletonWindow; |
58 | 58 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
59 |
import com.iver.cit.gvsig.fmap.MapContext; |
|
60 |
import com.iver.cit.gvsig.gui.JUnitsComboBox; |
|
59 | 61 |
import com.iver.cit.gvsig.gui.panels.CRSSelectPanel; |
60 | 62 |
import com.iver.cit.gvsig.project.documents.layout.Attributes; |
61 | 63 |
import com.iver.cit.gvsig.project.documents.view.ProjectView; |
... | ... | |
277 | 279 |
*/ |
278 | 280 |
private javax.swing.JComboBox getCmbMapUnits() { |
279 | 281 |
if (cmbMapUnits == null) { |
280 |
cmbMapUnits = new javax.swing.JComboBox(getUnitsNames()); |
|
282 |
boolean includePixels; |
|
283 |
cmbMapUnits = new JUnitsComboBox(includePixels = false); |
|
284 |
|
|
285 |
// cmbMapUnits = new javax.swing.JComboBox(getUnitsNames()); |
|
281 | 286 |
cmbMapUnits.setPreferredSize(new java.awt.Dimension(200, 20)); |
282 | 287 |
IProjection proj=view.getProjection(); |
283 | 288 |
if (!proj.isProjected()) { |
284 |
if (cmbMapUnits.getItemCount()==Attributes.NAMES.length) {
|
|
285 |
cmbMapUnits.addItem(PluginServices.getText(this, Attributes.DEGREES)); |
|
286 |
} |
|
287 |
cmbMapUnits.setSelectedItem(PluginServices.getText(this, Attributes.DEGREES));
|
|
289 |
// if (cmbMapUnits.getItemCount()==MapContext.NAMES.length) {
|
|
290 |
// cmbMapUnits.addItem(PluginServices.getText(this, Attributes.DEGREES));
|
|
291 |
// }
|
|
292 |
cmbMapUnits.setSelectedItem(MapContext.NAMES[8]); // deegree
|
|
288 | 293 |
cmbMapUnits.setEnabled(false); |
289 | 294 |
}else { |
290 |
if (!(cmbMapUnits.getItemCount()==Attributes.NAMES.length)) {
|
|
291 |
cmbMapUnits.removeItem(PluginServices.getText(this, Attributes.DEGREES));
|
|
295 |
if (!(cmbMapUnits.getItemCount()==MapContext.NAMES.length)) {
|
|
296 |
cmbMapUnits.removeItem(MapContext.NAMES[8]); // deegree
|
|
292 | 297 |
view.getMapContext().getViewPort().setMapUnits(1); |
293 | 298 |
} |
294 | 299 |
cmbMapUnits.setSelectedIndex(view.getMapContext().getViewPort().getMapUnits()); |
... | ... | |
296 | 301 |
} |
297 | 302 |
cmbMapUnits.setSelectedIndex(view.getMapContext().getViewPort().getMapUnits()); |
298 | 303 |
|
299 |
cmbMapUnits.addActionListener(new java.awt.event.ActionListener() { |
|
300 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
301 |
//view.getMapContext().getViewPort().setMapUnits(cmbMapUnits.getSelectedIndex()); |
|
302 |
} |
|
303 |
}); |
|
304 |
// |
|
305 |
// cmbMapUnits.addActionListener(new java.awt.event.ActionListener() { |
|
306 |
// public void actionPerformed(java.awt.event.ActionEvent e) { |
|
307 |
// //view.getMapContext().getViewPort().setMapUnits(cmbMapUnits.getSelectedIndex()); |
|
308 |
// } |
|
309 |
// }); |
|
304 | 310 |
} |
305 | 311 |
|
306 | 312 |
return cmbMapUnits; |
... | ... | |
328 | 334 |
*/ |
329 | 335 |
private javax.swing.JComboBox getCmbDistanceUnits() { |
330 | 336 |
if (cmbDistanceUnits == null) { |
331 |
cmbDistanceUnits = new javax.swing.JComboBox(getUnitsNames()); |
|
337 |
cmbDistanceUnits = new JUnitsComboBox(); |
|
338 |
// cmbDistanceUnits = new javax.swing.JComboBox(getUnitsNames()); |
|
332 | 339 |
cmbDistanceUnits.setPreferredSize(new java.awt.Dimension(200, 20)); |
333 |
cmbDistanceUnits.setEditable(false); |
|
334 |
cmbDistanceUnits.setSelectedIndex(view.getMapContext().getViewPort().getDistanceUnits()); |
|
335 |
cmbDistanceUnits.addActionListener(new java.awt.event.ActionListener() { |
|
336 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
337 |
//view.getMapContext().getViewPort().setDistanceUnits(cmbDistanceUnits.getSelectedIndex()); |
|
338 |
} |
|
339 |
}); |
|
340 |
// cmbDistanceUnits.setEditable(false);
|
|
341 |
// cmbDistanceUnits.setSelectedIndex(view.getMapContext().getViewPort().getDistanceUnits());
|
|
342 |
// cmbDistanceUnits.addActionListener(new java.awt.event.ActionListener() {
|
|
343 |
// public void actionPerformed(java.awt.event.ActionEvent e) {
|
|
344 |
// //view.getMapContext().getViewPort().setDistanceUnits(cmbDistanceUnits.getSelectedIndex());
|
|
345 |
// }
|
|
346 |
// });
|
|
340 | 347 |
} |
341 | 348 |
|
342 | 349 |
return cmbDistanceUnits; |
... | ... | |
618 | 625 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
619 | 626 |
if (jPanelProj.isOkPressed()) { |
620 | 627 |
if (!jPanelProj.getCurProj().isProjected()) { |
621 |
if (getCmbMapUnits().getItemCount()==Attributes.NAMES.length) {
|
|
628 |
if (getCmbMapUnits().getItemCount()==MapContext.NAMES.length) {
|
|
622 | 629 |
getCmbMapUnits().addItem(PluginServices.getText(this, Attributes.DEGREES)); |
623 | 630 |
} |
624 | 631 |
getCmbMapUnits().setSelectedItem(PluginServices.getText(this, Attributes.DEGREES)); |
... | ... | |
628 | 635 |
getCmbMapUnits().setSelectedIndex(1); |
629 | 636 |
getCmbMapUnits().setEnabled(true); |
630 | 637 |
} |
631 |
if (!(getCmbMapUnits().getItemCount()==Attributes.NAMES.length)) {
|
|
638 |
if (!(getCmbMapUnits().getItemCount()==MapContext.NAMES.length)) {
|
|
632 | 639 |
getCmbMapUnits().removeItem(PluginServices.getText(this, Attributes.DEGREES)); |
633 | 640 |
} |
634 | 641 |
} |
... | ... | |
687 | 694 |
return okCancelPanel; |
688 | 695 |
} |
689 | 696 |
|
690 |
private String[] getUnitsNames() { |
|
691 |
if (unitsNames == null) { |
|
692 |
unitsNames = new String[Attributes.NAMES.length];
|
|
693 |
int i=0; |
|
694 |
for (i=0;i<Attributes.NAMES.length;i++) {
|
|
695 |
unitsNames[i]=PluginServices.getText(this, Attributes.NAMES[i]);
|
|
696 |
} |
|
697 |
//unitsNames[i]=PluginServices.getText(this, Attributes.DEGREES); |
|
698 |
} |
|
699 |
return unitsNames; |
|
700 |
} |
|
697 |
// private String[] getUnitsNames() {
|
|
698 |
// if (unitsNames == null) {
|
|
699 |
// unitsNames = new String[MapContext.NAMES.length];
|
|
700 |
// int i=0;
|
|
701 |
// for (i=0;i<MapContext.NAMES.length;i++) {
|
|
702 |
// unitsNames[i]=PluginServices.getText(this, MapContext.NAMES[i]);
|
|
703 |
// }
|
|
704 |
// //unitsNames[i]=PluginServices.getText(this, Attributes.DEGREES);
|
|
705 |
// }
|
|
706 |
// return unitsNames;
|
|
707 |
// }
|
|
701 | 708 |
|
702 | 709 |
public boolean isAcceppted() { |
703 | 710 |
return isAcceppted; |
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/ImageSizePanel.java | ||
---|---|---|
151 | 151 |
return d; |
152 | 152 |
} |
153 | 153 |
|
154 |
public double getUnitConversionFactor() { |
|
155 |
return cmbUnits.getUnitConversionFactor(); |
|
156 |
} |
|
157 |
|
|
154 | 158 |
public void addActionListener(ActionListener l) { |
155 | 159 |
listeners .add(l); |
156 | 160 |
} |
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/JUnitsComboBox.java | ||
---|---|---|
40 | 40 |
*/ |
41 | 41 |
package com.iver.cit.gvsig.gui; |
42 | 42 |
|
43 |
import java.util.Vector; |
|
44 |
|
|
45 |
import javax.swing.ComboBoxModel; |
|
46 |
|
|
47 | 43 |
import com.iver.andami.PluginServices; |
48 |
import com.iver.cit.gvsig.project.documents.layout.Attributes;
|
|
44 |
import com.iver.cit.gvsig.fmap.MapContext;
|
|
49 | 45 |
import com.iver.utiles.swing.JComboBox; |
50 | 46 |
|
51 | 47 |
/** |
... | ... | |
61 | 57 |
private static final long serialVersionUID = 8015263853737441433L; |
62 | 58 |
|
63 | 59 |
/** |
64 |
* Creates a new instance of JUnitComboBox leaving "pixel" units automatically
|
|
65 |
* pre-selected. |
|
60 |
* Creates a new instance of JUnitComboBox including "pixel" units and
|
|
61 |
* setting them as automatically pre-selected.
|
|
66 | 62 |
*/ |
67 | 63 |
public JUnitsComboBox() { |
64 |
this(true); |
|
65 |
// super(); |
|
66 |
// String[] units = new String[MapContext.NAMES.length+1]; |
|
67 |
// for (int i = 0; i < MapContext.NAMES.length; i++) { |
|
68 |
// units[i] = PluginServices.getText(this, MapContext.NAMES[i]); |
|
69 |
// } |
|
70 |
// units[units.length-1] = PluginServices.getText(this, "pixels"); |
|
71 |
// |
|
72 |
// for (int i = 0; i < units.length; i++) { |
|
73 |
// super.addItem(units[i]); |
|
74 |
// } |
|
75 |
// setSelectedIndex(units.length-1); |
|
76 |
|
|
77 |
} |
|
78 |
|
|
79 |
/** |
|
80 |
* |
|
81 |
* Creates a new instance of JUnitComboBox. If includePixel is true |
|
82 |
* then pixel units are included in the list and they are automatically |
|
83 |
* pre-selected. Otherwise, meters are preselected. |
|
84 |
* |
|
85 |
*/ |
|
86 |
public JUnitsComboBox(boolean includePixel) { |
|
68 | 87 |
super(); |
69 |
String[] units = new String[Attributes.NAMES.length+1];
|
|
70 |
for (int i = 0; i < Attributes.NAMES.length; i++) {
|
|
71 |
units[i] = PluginServices.getText(this, Attributes.NAMES[i]);
|
|
88 |
String[] units = new String[MapContext.NAMES.length];
|
|
89 |
for (int i = 0; i < MapContext.NAMES.length; i++) {
|
|
90 |
units[i] = PluginServices.getText(this, MapContext.NAMES[i]);
|
|
72 | 91 |
} |
73 |
units[units.length-1] = PluginServices.getText(this, "pixels"); |
|
74 | 92 |
|
75 | 93 |
for (int i = 0; i < units.length; i++) { |
76 | 94 |
super.addItem(units[i]); |
77 | 95 |
} |
78 |
setSelectedIndex(units.length-1); |
|
96 |
if (includePixel) { |
|
97 |
super.addItem(PluginServices.getText(this, "pixels")); |
|
98 |
setSelectedIndex(units.length-1); |
|
99 |
} else { |
|
100 |
setSelectedIndex(1); |
|
101 |
} |
|
79 | 102 |
|
80 | 103 |
} |
81 | 104 |
|
105 |
|
|
82 | 106 |
/** |
83 | 107 |
* Returns the conversion factor from the <b>unit selected in the combo box</b> |
84 | 108 |
* to <b>meters</b> or <b>0</b> if pixels have been selected as the size unit. |
... | ... | |
87 | 111 |
public double getUnitConversionFactor() { |
88 | 112 |
double unitFactor; |
89 | 113 |
try { |
90 |
unitFactor = Attributes.CHANGE[getSelectedIndex()]/100;
|
|
114 |
unitFactor = MapContext.CHANGEM[getSelectedIndex()];
|
|
91 | 115 |
} catch (ArrayIndexOutOfBoundsException aioobEx) { //jijiji |
92 | 116 |
unitFactor = 0; // which represents size in pixel |
93 | 117 |
} |
Also available in: Unified diff